daily pastebin goal
15%
SHARE
TWEET

e20

a guest Feb 18th, 2019 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. memo = dict()
  2. memo[1] = 1
  3.  
  4. def factorial(n):
  5.     if n in memo:
  6.         return n
  7.     else:
  8.         val = n * factorial(n - 1)
  9.         memo[n] = val
  10.         return val
  11.  
  12. # print(factorial(1))
  13. # print(factorial(2))
  14. # f100 = factorial(100)
  15. # print(f100)
  16. # tokens = list(str(f100))
  17. # print(tokens)
  18. # print(sum([int(x) for x in tokens]))
  19. print(sum([int(x) for x in list(str(factorial(100)))]))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top