Skip to content

Commit 0cbfa27

Browse files
author
Akash Kumar
authored
Update sol1.py
1 parent a42997e commit 0cbfa27

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

project_euler/problem_301/sol1.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,14 @@ def solution(exponent: int = 30) -> int:
4444
3
4545
>>> solution(10)
4646
144
47-
>>> solution(30)
48-
2178309
4947
"""
5048
# To find how many total games were lost for a given exponent x,
5149
# we need to find the Fibonacci number F(x+2).
52-
fib_ind = exponent + 2
50+
fibonacci_index = exponent + 2
5351
phi = (1 + 5 ** 0.5) / 2
54-
fib = (phi ** fib_ind - (phi - 1) ** fib_ind) / 5 ** 0.5
55-
nim_loss_count = int(fib)
52+
fibonacci = (phi ** fibonacci_index - (phi - 1) ** fibonacci_index) / 5 ** 0.5
5653

57-
return nim_loss_count
54+
return int(fibonacci)
5855

5956

6057
if __name__ == "__main__":

0 commit comments

Comments
 (0)