File tree 1 file changed +38
-0
lines changed
1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change
1
+ """ Problem Statement (Digit Fifth Power ):
2
+ Surprisingly there are only three numbers that can be written as the sum of fourth powers of their digits:
3
+
4
+ 1634 = 14 + 64 + 34 + 44
5
+ 8208 = 84 + 24 + 04 + 84
6
+ 9474 = 94 + 44 + 74 + 44
7
+ As 1 = 14 is not a sum it is not included.
8
+
9
+ The sum of these numbers is 1634 + 8208 + 9474 = 19316.
10
+
11
+ Find the sum of all the numbers that can be written as the sum of fifth powers of their digits.
12
+
13
+ """
14
+ """
15
+ (9^5)=59,049
16
+ 59049*7=4,13,343 (which is only 6 digit number )
17
+ So, number greater than 9,99,999 are rejected
18
+ and also 59049*3=1,77,147 (which exceeds the criteria of number being 3 digit)
19
+ So, n>999
20
+ and hence a bound between (1000,1000000)
21
+ """
22
+
23
+
24
+ def digitsum (s ):
25
+ c = 0
26
+ for j in range (len (s )):
27
+ c += pow (int (s [j ]),5 )
28
+ if c == int (s ):
29
+ return c
30
+ else :
31
+ return 0
32
+
33
+ count = 0
34
+ for i in range (1000 ,1000000 ):
35
+ count += digitsum (str (i ))
36
+ print (count )
37
+
38
+ #ans = 443839
You can’t perform that action at this time.
0 commit comments