Surprisingly there are only three numbers that can be written as the sum of fourth powers of their digits:
1 6 3 4 = 1 4 + 6 4 + 3 4 + 4 4
8 2 0 8 = 8 4 + 2 4 + 0 4 + 8 4
9 4 7 4 = 9 4 + 4 4 + 7 4 + 4 4
The sum of these numbers is 1 6 3 4 + 8 2 0 8 + 9 4 7 4 = 1 9 3 1 6 .
Find the sum of all the numbers (less than 1 million) that can be written as the sum of fifth powers of their digits.
Note: 1 5 = 1 is not considered a sum and it is not included.
Try other problems Here
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
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 28 |
|
Here's some primitive code (Python)
msum = 0
for j in range(1,10**6):
num = j
####################################
p6 = num / (10**6)
num = num % (10**6)
####################################
p5 = num / (10**5)
num = num % (10**5)
####################################
p4 = num / (10**4)
num = num % (10**4)
####################################
p3 = num / (10**3)
num = num % (10**3)
####################################
p2 = num / (10**2)
num = num % (10**2)
####################################
p1 = num / (10**1)
num = num % (10**1)
####################################
p0 = num / (10**0)
num = num % (10**0)
####################################
q = p6**5 + p5**5 + p4**5 + p3**5 + p2**5 + p1**5 + p0**5
res = q - j
if res == 0:
msum = msum + j
print j
print ""
print ""
print (msum - 1)
####### Results #######
1
4150
4151
54748
92727
93084
194979
443839
Type your code like this
"```python
```"
Without Quotes, it will show numbers Too and looks beautiful.
BTW nice solution.
Problem Loading...
Note Loading...
Set Loading...
Small Python Script :