diff --git a/src/Python/Problems001-050/Problem025.py b/src/Python/Problems001-050/Problem025.py index 5cb47c5..7fcbacd 100644 --- a/src/Python/Problems001-050/Problem025.py +++ b/src/Python/Problems001-050/Problem025.py @@ -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()}") \ No newline at end of file + print(f"Result for Problem 25 is {compute()}")