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 06dbef0 commit 7b89d03Copy full SHA for 7b89d03
project_euler/problem_02/sol4.py
@@ -0,0 +1,13 @@
1
+import math
2
+from decimal import *
3
+
4
+getcontext().prec = 100
5
+phi = (Decimal(5) ** Decimal(0.5) + 1) / Decimal(2)
6
7
+n = Decimal(int(input()) - 1)
8
9
+index = (math.floor(math.log(n * (phi + 2), phi) - 1) // 3) * 3 + 2
10
+num = round(phi ** Decimal(index + 1)) / (phi + 2)
11
+sum = num // 2
12
13
+print(int(sum))
0 commit comments