2019-08-16 05:05:39 +02:00
|
|
|
from functools import lru_cache
|
|
|
|
|
|
|
|
|
|
|
|
@lru_cache(maxsize=1000000)
|
|
|
|
def possible_sums(n, n_orig, d):
|
|
|
|
if d == n_orig:
|
|
|
|
return 0
|
|
|
|
if n == 0:
|
|
|
|
return 1
|
|
|
|
if n < 0:
|
|
|
|
return 0
|
|
|
|
if d > n:
|
|
|
|
return 0
|
|
|
|
return possible_sums(n - d, n_orig, d) + possible_sums(n, n_orig, d + 1)
|
|
|
|
|
|
|
|
|
2019-08-16 05:26:47 +02:00
|
|
|
def euler_076():
|
2019-08-16 05:05:39 +02:00
|
|
|
return possible_sums(100, 100, 1)
|
|
|
|
|
|
|
|
|
2019-08-16 05:26:47 +02:00
|
|
|
if __name__ == "__main__":
|
|
|
|
print("e076.py: " + str(euler_076()))
|
|
|
|
assert(euler_076() == 190569291)
|