Kelvin
0
Q:

Write a program that asks the user to enter an integer and prints two integers, root and pwr, such that 0 < pwr < 6 and root**pwr is equal to the integer entered by the user. If no such pair of integers exists, it should print a message to that effect.

#Write a program that asks the user to enter an integer and prints two integers,
#root and pwr, such that 0 < pwr < 6 and root ** pwr is equal to the integer entered
# by the user. If no such pair of integers exist, it should print a message to that effect.
 
 
x = int(input("Enter an integer: "))
pwr = 1 
while pwr < 6 :
    if x < 0:
        root = x
    else:
        root = 0 
    while root ** pwr <= x:
        if root ** pwr == x:
            print(root, " ** ", pwr, "=", x)
        else:
            if x ** 1 != x:
                print(x, "No such integer pair exists.")
        root += 1
    pwr += 1
0

New to Communities?

Join the community