fb pixel

Is it a power of 2?

Given a positive integer n, your task is to find out if it’s a power of 2 or not.
In case it’s a power of 2, the program should print Yes, and it should print No otherwise.
Input
Output
1
Yes
8
Yes
15
No
 
 
Hint
You can have an auxiliary variable powerof2 = True and update it accordingly
 
To check your solution you need to sign in
Sign in to continue