Find the next fibonacci number | C ++ implementation of the approach ; Function to return the next fibonacci number ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int nextFibonacci ( int n ) { double a = n * ( 1 + sqrt ( 5 ) ) / 2.0 ; return round ( a ) ; } int main ( ) { int n = 5 ; cout << nextFibonacci ( n ) ; }