Enter an integer n between 0 and 10000 inclusive to calculate the nth fibonacci number.
What is a Fibonacci Number?
Fibonacci numbers are a sequence Fn of non-negative integer numbers where each consecutive number is the sum of the two prior numbers in the sequence, except for zero and one, which equal themselves.
The golden ratio (1.618033988749894...) can be closely approximated by the ratio of two consecutive fibonacci numbers. For example: F20 / F19 = 6765 / 4181 = 1.618034...
Fibonacci numbers often occur in nature. Some examples include the branching of a tree, the arrangements of leaves on a stem, or the number of petals on a flower.
How do you calculate a Fibonacci number?
The nth fibonacci number can be calculated either recursively or explicitly.
To calculate a fibonacci number recursively, start with F0 = 0, F1 = 1, and continue adding the previous two numbers until you get the nth number.
To calculate a fibonacci number explicitly, use Binet's formula:
((1 + √5)n − (1 − √5)n) / (2n√5).