BlueBook
p129ex3 - Powers of 2
Write a program that reads a positive integer and then finds the smallest power of two greater than or equal to the number that was read.
Input
Each test case will input a single integer number.
Output
You are to output a single integer number.
Sample Input
200
Sample Output
8
All Submissions
Best Solutions
Point Value: 3
Time Limit: 2.00s
Memory Limit: 16M
Added: Oct 22, 2008
Languages Allowed:
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3
Comments (Search)
The sample output is 8 because 2^8 = 256 > 200 > 128 = 2^7.
Waiting for other submissions to finish...
Remainder 2^0=1
When I run your code (submission 51610), it doesn't even work on the sample data.
-Mr. Fenty
Output the exponent A where 2 to the power of A is <= to N.
P.S. The output was wrong for 2 cases, but I changed that.
Toby Li.