The Fibonacci sequence is defined by the recurrence relation:
Fn = Fn1 + Fn2, where F1 = 1 and F2 = 1.
Hence the first 12 terms will be:
F1 = 1
F2 = 1
F3 = 2
F4 = 3
F5 = 5
F6 = 8
F7 = 13
F8 = 21
F9 = 34
F10 = 55
F11 = 89
F12 = 144
The 12th term, F12, is the first term to contain three digits.
What is the first term in the Fibonacci sequence to contain 1000 digits?
;fibo (defn p25 [] (println (count (take-while #(< (count (str %)) 1000) (fibo))) ) )
%pow p25()->io:format("~w~n",[p25(0,1,pow(10,999),1)]). p25(_,B,Limit,I) when B >= Limit ->I; p25(A,B,Limit,I)->p25(B,A+B,Limit,I+1).
def p25 limit=10**999 a,b,i=0,1,1 a,b,i=b,a+b,i+1 while b<limit puts i end