We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a42997e commit 0cbfa27Copy full SHA for 0cbfa27
project_euler/problem_301/sol1.py
@@ -44,17 +44,14 @@ def solution(exponent: int = 30) -> int:
44
3
45
>>> solution(10)
46
144
47
- >>> solution(30)
48
- 2178309
49
"""
50
# To find how many total games were lost for a given exponent x,
51
# we need to find the Fibonacci number F(x+2).
52
- fib_ind = exponent + 2
+ fibonacci_index = exponent + 2
53
phi = (1 + 5 ** 0.5) / 2
54
- fib = (phi ** fib_ind - (phi - 1) ** fib_ind) / 5 ** 0.5
55
- nim_loss_count = int(fib)
+ fibonacci = (phi ** fibonacci_index - (phi - 1) ** fibonacci_index) / 5 ** 0.5
56
57
- return nim_loss_count
+ return int(fibonacci)
58
59
60
if __name__ == "__main__":
0 commit comments