mirror of
https://github.com/correl/euler.git
synced 2024-11-30 11:09:52 +00:00
Problem 030
git-svn-id: file:///srv/svn/euler@58 e5f4c3ec-3c0c-11df-b522-21efaa4426b5
This commit is contained in:
parent
3807d9f5bf
commit
d9b2e17675
1 changed files with 16 additions and 0 deletions
16
e030.py
Normal file
16
e030.py
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
def power_sums(n):
|
||||||
|
numbers = []
|
||||||
|
i = 9
|
||||||
|
while i <= 10**(n+1):
|
||||||
|
i = i + 1
|
||||||
|
if int(max(str(i)))**n > i:
|
||||||
|
continue
|
||||||
|
s = sum([int(c)**n for c in str(i)])
|
||||||
|
if i == s:
|
||||||
|
numbers.append(i)
|
||||||
|
return numbers
|
||||||
|
|
||||||
|
p = power_sums(4)
|
||||||
|
print 'power_sums(4)', p, sum(p)
|
||||||
|
p = power_sums(5)
|
||||||
|
print 'power_sums(5)', p, sum(p)
|
Loading…
Reference in a new issue