Files
project-euler/problem_25.py
MitchellHansen 13a163e81d problem 25
2017-03-13 23:25:52 -07:00

25 lines
501 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# The Fibonacci sequence is defined by the recurrence relation:
#
# Fn = Fn1 + Fn2, where F1 = 1 and F2 = 1.
#
# The 12th term, F12, is the first term to contain three digits.
#
# What is the index of the first term in the Fibonacci sequence to contain 1000 digits?
n_minus_1 = 1
n_minus_2 = 1
value = 0
index = 3
while True:
value = n_minus_1 + n_minus_2
if len(str(value)) == 1000:
print(index)
break
n_minus_2 = n_minus_1
n_minus_1 = value
index += 1