From d9b2e17675c0b60f463cb708b150839171ace3a3 Mon Sep 17 00:00:00 2001 From: Correl Roush Date: Mon, 3 May 2010 23:32:37 +0000 Subject: [PATCH] Problem 030 git-svn-id: file:///srv/svn/euler@58 e5f4c3ec-3c0c-11df-b522-21efaa4426b5 --- e030.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 e030.py diff --git a/e030.py b/e030.py new file mode 100644 index 0000000..f3fa3a6 --- /dev/null +++ b/e030.py @@ -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)