Home > Problem, Projects/Experiments, Python > Python: Powerful Digit Counts

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
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s