#K45927. Sum of Fibonacci Numbers

    ID: 27862 Type: Default 1000ms 256MiB

Sum of Fibonacci Numbers

Sum of Fibonacci Numbers

You are given an integer ( n ). Your task is to compute the sum of the first ( n ) Fibonacci numbers. The Fibonacci sequence is defined as follows:

[ F_0 = 0,\quad F_1 = 1,\quad F_n = F_{n-1} + F_{n-2} \text{ for } n \ge 2. ]

For example, when ( n = 5 ), the first five Fibonacci numbers are: (0, 1, 1, 2, 3), and their sum is (0 + 1 + 1 + 2 + 3 = 7).

inputFormat

The input consists of a single integer ( n ) (( n \geq 1 )), which represents the number of Fibonacci numbers to sum. The input is provided via standard input (stdin).

outputFormat

Output a single integer representing the sum of the first ( n ) Fibonacci numbers. The answer should be printed to standard output (stdout).## sample

1
0

</p>