Re:A program to compute the nth Fibonacci number
by pavpanchekha on Saturday April 28, 2012 @04:14PM
(#3903956)
1) You don't really need the (b) term. (1 - \phi) is on the order of .5, so if you round the result of ((a - b) / c) instead of truncating it, you can ignore that term.
2) How long are your floating point numbers? You code works for n up to 71, but no further. The linked example works for any n.
Every time Fibonacci is discussed, someone brings up the Binet formula. If I'm interviewing for a position that requires any sort of numeric coding, this is a reason not to hire -- it demonstrates you don't know the first things about floating point.
2) How long are your floating point numbers? You code works for n up to 71, but no further. The linked example works for any n.
Every time Fibonacci is discussed, someone brings up the Binet formula. If I'm interviewing for a position that requires any sort of numeric coding, this is a reason not to hire -- it demonstrates you don't know the first things about floating point.