Solve more problems road to 200.
This commit is contained in:
20
python/e148.py
Normal file
20
python/e148.py
Normal file
@@ -0,0 +1,20 @@
|
||||
def count(i, s, c, depth):
|
||||
if depth == 0:
|
||||
return s + i, c + 1
|
||||
for i in range(i, i * 8, i):
|
||||
s, c = count(i, s, c, depth - 1)
|
||||
if c == 10**9:
|
||||
break
|
||||
return s, c
|
||||
|
||||
|
||||
def euler_148():
|
||||
s, c = count(1, 0, 0, 11)
|
||||
assert c == 10**9
|
||||
return s
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
solution = euler_148()
|
||||
print("e148.py: " + str(solution))
|
||||
assert solution == 2129970655314432
|
||||
Reference in New Issue
Block a user