Advertisement
Guest User

Untitled

a guest
Dec 13th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. x = int(input())
  2. for pwr in range(1,6):
  3. root = 0
  4. while root**pwr < abs(x):
  5. root += 1
  6. if root**pwr != abs(x) or (x < 0 and pwr % 2 == 0):
  7. print(x, ' is not a power of a ', pwr)
  8. else:
  9. if x < 0:
  10. root = -root #root *= -1
  11. print("{} is {}ˆ{}".format(x, root, pwr))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement