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 7beaeae commit 301c907Copy full SHA for 301c907
Project Euler/Problem 25/sol1.py
@@ -0,0 +1,26 @@
1
+from __future__ import print_function
2
+
3
+def fibonacci(n):
4
+ if n == 1 or type(n) is not int:
5
+ return 0
6
+ elif n == 2:
7
+ return 1
8
+ else:
9
+ sequence = [0, 1]
10
+ for i in xrange(2, n+1):
11
+ sequence.append(sequence[i-1] + sequence[i-2])
12
13
+ return sequence[n]
14
15
+def fibonacci_digits_index(n):
16
+ digits = 0
17
+ index = 2
18
19
+ while digits < n:
20
+ index += 1
21
+ digits = len(str(fibonacci(index)))
22
23
+ return index
24
25
+if __name__ == '__main__':
26
+ print(fibonacci_digits_index(1000))
0 commit comments