Python-Check a Number is Power of 2

--

Photo by Priscilla Du Preez on Unsplash

Python program to check if a given number is the power of two.

If you multiply x and y then z=x*y. — — -1

z=2^a, z=2^(c+d), z=2^c * 2^d — — 2

from Equ1 and Equ2

x=2^c and y =2^d

i.e if x and y are the power of 2 then their multiplication is also the power of 2 and vice versa

Following is a python program to check if a number is the power of 2 or not.

Note: Please feel free to comment if you find any errors. Also, suggest for improvisation of the code, if you feel it.

--

--