36. Nth Fibonacci Number
Core1000 ms256 MBSolved by 0%
The Fibonacci sequence starts 0, 1, 1, 2, 3, 5, 8, ..., each number is
the sum of the two before it.
Read n and print the nth number in the sequence, counting from 0. So input 0 gives
0, input 1 gives 1, and input 6 gives 8.
Constraints - `0 ≤ n ≤ 90`
Input
A single line containing one integer n.
Output
Print one integer, the nth Fibonacci number, counting from 0.
Input6
Output8
Noteis the worked example from the statement
Input0
Output0
Noteis the first term, which a loop starting at 1 would skip
Hints
Four rungs, in order. The last two open once you have submitted an attempt. A wrong one counts.
Hint 1Where to start
Hint 2The approachOpen hint 1 first. This one carries on from it.
Hint 3PseudocodeOpen hint 2 first. This one carries on from it.
Hint 4Full solutionOpen hint 3 first. This one carries on from it.