fork(2) download
  1. def isPowerOf(n,r):
  2. if n==1:
  3. return True
  4. elif n%r == 0:
  5. return isPowerOf(n//r,r)
  6. else:
  7. return False
  8.  
  9. print(isPowerOf(1024,2))
  10. print(isPowerOf(81,2))
  11. print(isPowerOf(81,3))
  12.  
Success #stdin #stdout 0.01s 27712KB
stdin
Standard input is empty
stdout
True
False
True