Skip to content

Instantly share code, notes, and snippets.

@hamzafarooq
Created July 22, 2020 06:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hamzafarooq/6a6991d2c490c840d70d140df3321a17 to your computer and use it in GitHub Desktop.
Save hamzafarooq/6a6991d2c490c840d70d140df3321a17 to your computer and use it in GitHub Desktop.
import numpy as np
def powerof2(num):
if num <= 0:
return False
if num == 1:
return True
max = int(round(num/2,0))
j=0
for i in range(max+1):
if i*i==num:
j=1
return (j==1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment