diff options
Diffstat (limited to 'Problem34.py')
-rw-r--r-- | Problem34.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Problem34.py b/Problem34.py new file mode 100644 index 0000000..07d7146 --- /dev/null +++ b/Problem34.py @@ -0,0 +1,20 @@ +#completed on 9/13/2021 15:26 +def factorial(n): + for x in range(2,n): + n = n*x + return n +def factorialSum(n): + m,sum = str(n),0 + for x in range(0,len(m)): + if int(m[x]) == 0: + sum += 1 + else: + sum += factorial(int(m[x])) + if sum > n: return False + if sum == n: return True + else: return False +sum = 0 +for x in range(10,2540161,1): + if factorialSum(x) == True: + sum += x +print("Solution is:" ,sum) |