Pentanacci Numbers | A simple recursive program to print Nth Pentanacci number ; Recursive function to find the Nth Pentanacci number ; Function to print the Nth Pentanacci number ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int printpentaRec ( int n ) { if ( n == 0 n == 1 n == 2 n == 3 n == 4 ) return 0 ; else if ( n == 5 ) return 1 ; else return ( printpentaRec ( n - 1 ) + printpentaRec ( n - 2 ) + printpentaRec ( n - 3 ) + printpentaRec ( n - 4 ) + printpentaRec ( n - 5 ) ) ; } void printPenta ( int n ) { cout << printpentaRec ( n ) << " STRNEWLINE " ; } int main ( ) { int n = 10 ; printPenta ( n ) ; return 0 ; }