Program to find Nth odd Fibonacci Number | C ++ program for Nth odd fibonacci number ; Function to find nth odd fibonacci number ; Driver Code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int oddFib ( int n ) { n = ( 3 * n + 1 ) / 2 ; int a = -1 , b = 1 , c , i ; for ( i = 1 ; i <= n ; i ++ ) { c = a + b ; a = b ; b = c ; } return c ; } int main ( ) { int n = 4 ; cout << oddFib ( n ) ; return 0 ; }