Fibonacci (DP, not recursion)

VERY EASY · C · 2000ms

Puzzle-club president Dip is prepping brain-teasers for the club's game night. Warm-up: compute a large Fibonacci number efficiently, without letting recursion blow the stack. Read N. Print the N-th Fibonacci number (F(1)=1, F(2)=1) using an iterative DP array or two rolling variables — NOT plain recursion (too slow for large N).

Input

One integer N.

Output

F(N).

Constraints

1 ≤ N ≤ 90

Sample Input

10

Sample Output

55
main.c
Loading editor…

Write C, then Run (custom I/O) or Submit (sample tests). ⌘/Ctrl+Enter submits.

Fibonacci (DP, not recursion) · DIU ContestHub