Archive

Archive for July 15, 2019

Python: Powerful Digit Counts



Python: Powerful Digit Counts
Problem No.63 @ ProjectEuler
Completed on: Completed on Thu, 11 Jul 2019, 17:21

Just to make my post simple, i am quoting from ProjectEuler page

The 5-digit number, 16807=75, is also a fifth power. Similarly, the 9-digit number, 134217728=89, is a ninth power.
How many n-digit positive integers exist which are also an nth power?


Then, we need to find the loop that will solve this, and we did..



The Code:



# P63
# Power digit count
# Solved
# Completed on Thu, 11 Jul 2019, 17:21

c = 0
for x in range (1,50):

for p in range (1,50) :

if (len(str(x**p)) == p ):

c += 1

print(‘\n We have {} n-digit integers exist which are also an nth power.’.format(c))






Follow me on Twitter..



Advertisements