Tetranacci Numbers | A simple recursive Java program to print the nth tetranacci numbers . ; Function to return the N - th tetranacci number ; base cases ; base cases ; base cases ; function to print the Nth tetranacci number ; Driver code
class GFG { static int printTetraRec ( int n ) { if ( n == 0 ) return 0 ; if ( n == 1 n == 2 ) return 1 ; if ( n == 3 ) return 2 ; else return printTetraRec ( n - 1 ) + printTetraRec ( n - 2 ) + printTetraRec ( n - 3 ) + printTetraRec ( n - 4 ) ; } static void printTetra ( int n ) { System . out . println ( printTetraRec ( n ) + " ▁ " ) ; } public static void main ( String [ ] args ) { int n = 10 ; printTetra ( n ) ; } }