Rebased projecteuler folder, now includes all contest programming stuff
This commit is contained in:
30
projecteuler/020/main.py
Normal file
30
projecteuler/020/main.py
Normal file
@@ -0,0 +1,30 @@
|
||||
import os
|
||||
import math
|
||||
import numpy as np
|
||||
|
||||
# Get the sum of all the digits of 100!
|
||||
|
||||
def fac(n):
|
||||
if n == 0:
|
||||
return 1
|
||||
|
||||
return n * fac(n-1)
|
||||
|
||||
def sumDigits(n):
|
||||
s = str(n)
|
||||
res = 0
|
||||
|
||||
for c in s:
|
||||
res = res + int(c)
|
||||
|
||||
return res
|
||||
|
||||
def main():
|
||||
print("Hello, this is Patrick")
|
||||
|
||||
f100 = fac(100)
|
||||
s100 = sumDigits(f100)
|
||||
print(s100)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user