+ 1

First power of 2

Hello.i must write a program that reads the number n, from input and prints the first power of the number two, which is greater than n. I have no idea for this. I just can use for,ifelse and I can't use any method or function or library. Can you help me?

30th Oct 2021, 11:06 AM
Marjaf
Marjaf - avatar
2 Antworten
+ 8
why not just start with a power of 2, check it against the input. If it's bigger print it, if not take 2 to the next power
30th Oct 2021, 11:09 AM
Slick
Slick - avatar
+ 3
Slick Thank you very much. It was a good idea and I wrote it.
30th Oct 2021, 3:05 PM
Marjaf
Marjaf - avatar