The Fibonacci sequence is defined by the recurrence relation:
, where
and
.
Hence the first 12 terms will be:
The 12th term, , is the first term to contain three digits.
What is the index of the first term in the Fibonacci sequence to contain 1000 digits?
Because numbers with so many digits are hard to represent in Javascript,
I used arrays of numbers instead.
I made a function to add arrays of numbers together from left to right then
I kept count of how many Fibonacci numbers I had cycled through. I also used
the formula
where
is the
Fibonacci number to act as a checksum and give me a rough idea
of what index I should be at.
138,843