While4. An integer N (>0) is given. If it is a power of 3, then output TRUE, if not, output FALSE.
Solution in Python 3:
import random
#N = random.randrange(1,1000)
N = 81
print('N = ', N)
while N >= 3:
N /= 3
print("Power of 3: ", (N==1))
While4. An integer N (>0) is given. If it is a power of 3, then output TRUE, if not, output FALSE.
Solution in Python 3:
import random
#N = random.randrange(1,1000)
N = 81
print('N = ', N)
while N >= 3:
N /= 3
print("Power of 3: ", (N==1))