text: Tetranacci Numbers | A DP based Java program to print the nth tetranacci number ; Function to print the N - th tetranacci number ; base cases ; Driver code
code: class GFG { static void printTetra ( int n ) { int [ ] dp = new int [ n + 5 ] ; dp [ 0 ] = 0 ; dp [ 1 ] = dp [ 2 ] = 1 ; dp [ 3 ] = 2 ; for ( int i = 4 ; i <= n ; i ++ ) dp [ i ] = dp [ i - 1 ] + dp [ i - 2 ] + dp [ i - 3 ] + dp [ i - 4 ] ; System . out . print ( dp [ n ] ) ; } public static void main ( String [ ] args ) { int n = 10 ; printTetra ( n ) ; } }