project_euler/25.rb
Code:
# Project Euler Problem 25: 1000-digit Fibonacci Number
# https://projecteuler.net/problem=25
# What is the index of the first term in the Fibonacci sequence
# to contain 1000 digits?
def solve(n)
a, b, i = 1, 1, 1
i, a, b = i + 1, b, a + b while a.to_s.size < n
return i
end
puts solve(3)
puts solve(1000)
Output:
12
4782