The very first thought likely to hit will be that of taking mod 2(%2) of numbers from 1 to 100 in a loop and checking whether it yield an remainder or not. But there is even better a way to deal with it.
for( unsigned int i = 1; i < = 100; i++ )
if( i & 0×00000001 )
cout << i<<” “;
The catch is, only odd number’s binary representation ends with ‘1’.Check the below table
|


Gud technique!!!
do you have someother methods
Good
What was meant by the statement :
“The catch is, only prime number’s binary representation ends with ‘1’”
9 is not a prime. However it also ends in ‘1′
“009 09 00001001″
Or did you mean something else?
It was a typo,I have corrected it
How about
for (unsigned int i = 1; i <= 100; i += 2)
cout << i << ” “;