[Haskell-beginners] For Euler 25; What is the first term in the Fibonacci sequence to contain 1000 digits?; the following seems to work.
KC
kc1956 at gmail.com
Thu May 19 19:29:27 CEST 2011
For Euler 25; What is the first term in the Fibonacci sequence to
contain 1000 digits?; the following seems to work.
-- For number of digits being 5 or more.
fibNdigits :: Int -> Int
fibNdigits nDigits = floor (((fromIntegral nDigits) - 1.0) / (logBase
10 phi)) + 2
where
sq5 = sqrt 5 :: Double
phi = (1 + sq5) / 2
--
--
Regards,
KC
More information about the Beginners
mailing list