Adopted new convention from template
This commit is contained in:
parent
20893290f4
commit
acb9f1f2ce
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
Created on 11 Sep 2019
|
||||
|
||||
@ -17,7 +17,7 @@ def compute():
|
||||
"""
|
||||
The Fibonacci sequence is defined by the recurrence relation:
|
||||
|
||||
Fn = Fn−1 + Fn−2, where F1 = 1 and F2 = 1.
|
||||
Fn = Fn-1 + Fn-2, where F1 = 1 and F2 = 1.
|
||||
|
||||
Hence the first 12 terms will be:
|
||||
|
||||
@ -39,16 +39,15 @@ def compute():
|
||||
What is the index of the first term in the Fibonacci sequence to
|
||||
contain 1000 digits?
|
||||
"""
|
||||
|
||||
a, b = 1, 1
|
||||
index = 2
|
||||
|
||||
ans = 2
|
||||
while len(str(b)) < 1000:
|
||||
a, b = b, b+a
|
||||
index += 1
|
||||
a, b = b, b + a
|
||||
ans += 1
|
||||
|
||||
return index
|
||||
return ans
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
print(f"Result for Problem 25: {compute()}")
|
||||
print(f"Result for Problem 25 is {compute()}")
|
||||
|
Loading…
x
Reference in New Issue
Block a user