4 ms·
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 t
by pavpanchekha 15y ago
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.
- xyzzyz 15y agoBinet formula needs not to be implemented using floating point numbers: https://github.com/xyzzyz/FibBinet https://github.com/xyzzyz/FibBinet