# SGU 123 - The Sum

## Description

The Fibonacci sequence of numbers is known: $F_1 = 1$; $F_2 = 1$; $F_{n+1} = F_n + F_{n-1}$, for $n>1$. You have to find $S$ - the sum of the first $K$ Fibonacci numbers.

## Input

First line contains natural number $K$ ($0<K<41$).

## Output

First line should contain number $S$.

## Sample Input

 1  5 

## Sample Output

 1  12 

## Solution

  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18  #include using namespace std; const int MAX = 64; int f[MAX]; int main() { int N; cin >> N; f[1] = f[2] = 1; for(int i = 3; i <= N + 2; i++) { f[i] = f[i - 1] + f[i - 2]; } cout << f[N + 2] - 1 << endl; return 0; }