Sum of Fibonacci Numbers | Set 2 | C ++ program for the above approach ; Function to find the sum of first N + 1 fibonacci numbers ; Apply the formula ; Print the result ; Driver Code
#include <bits/stdc++.h> NEW_LINE using namespace std ; void sumFib ( int N ) { long num = ( long ) round ( pow ( ( sqrt ( 5 ) + 1 ) / 2.0 , N + 2 ) / sqrt ( 5 ) ) ; cout << ( num - 1 ) ; } int main ( ) { int N = 3 ; sumFib ( N ) ; return 0 ; }