Memoization ( 1D , 2D and 3D ) | C ++ program to find the Nth term of Fibonacci series ; Fibonacci Series using Recursion ; Base case ; recursive calls ; Driver Code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int fib ( int n ) { if ( n <= 1 ) return n ; return fib ( n - 1 ) + fib ( n - 2 ) ; } int main ( ) { int n = 6 ; printf ( " % d " , fib ( n ) ) ; return 0 ; }