eolymp
bolt
Try our new interface for solving problems
Problems

Fibonacci Sequence

Fibonacci Sequence

The Fibonacci sequence is defined as follows: \begin{itemize} \item $a_0 = 0$, \item $a_1 = 1$, \item $a_k = a_{k-1} + a_{k-2}$ \end{itemize} For a given value of $n$, find the $n$-th element of the Fibonacci sequence. \InputFile One positive integer $n~(1 \le n \le 40)$. \OutputFile Print the $n$-th element of the Fibonacci sequence.
Time limit 1 second
Memory limit 128 MiB
Input example #1
2
Output example #1
1
Input example #2
5
Output example #2
5
Input example #3
8
Output example #3
21
Source 2012 All-Ukrainian Collegiate Programming Contest Round I Training Contest, April 19