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
import java . util . * ; class GFG { static 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 ) ) ; } static void printPenta ( int n ) { System . out . print ( printpentaRec ( n ) + "NEW_LINE"); } public static void main ( String [ ] args ) { int n = 10 ; printPenta ( n ) ; } }