Fibonacci Numbers Calculator
How This Converter Works
Computes the Fibonacci value F(n), where F(0)=0 and F(1)=1, for integer text accepted by the shared isDecimal helper (optional leading sign and decimal digits). The field is limited to two characters. The base-case comparisons use loose equality, so spellings such as 00 and +0 match zero; negative nonzero integers fall through the loop and return 1. Invalid integer text displays NAN.
Formula or rule
F(0)=0, F(1)=1, F(n)=F(n-1)+F(n-2); the code iterates adjacent values for n >= 2.
Example
- Input
- 8
- Calculation
- 0, 1, 1, 2, 3, 5, 8, 13, 21
- Result
- 21