-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproblem-063.py
More file actions
27 lines (23 loc) · 744 Bytes
/
Copy pathproblem-063.py
File metadata and controls
27 lines (23 loc) · 744 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
### Problem 63 - Powerful Digit Counts
###----------------------------------------------------------------------------------------------------------------------
### The 5-digit number, 16807=7^5, is also a fifth power. Similarly, the 9-digit number, 134217728=8^9, is a ninth power.
### How many n-digit positive integers exist which are also an nth power?
### Solution
numbers = []
number = 1
while True:
if number > 11:
break
exp = 1
while True:
power = pow(number, exp)
if len(str(power)) == exp:
numbers.append(power)
else:
break
exp += 1
number += 1
print(
"The number of n-digit positive numbers that are an nth power is: "
+ str(len(numbers))
)