Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- x = int(input())
- for pwr in range(1,6):
- root = 0
- while root**pwr < abs(x):
- root += 1
- if root**pwr != abs(x) or (x < 0 and pwr % 2 == 0):
- print(x, ' is not a power of a ', pwr)
- else:
- if x < 0:
- root = -root #root *= -1
- print("{} is {}ˆ{}".format(x, root, pwr))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement