Program to print tetrahedral numbers upto Nth term | Java program to generate series of tetrahedral numbers ; function to print tetrahedral number series up to n ; loop to print series ; Calculate and print ith tetrahedral number ; Driver code ; function call to print series
import java . io . * ; class GFG { static void printSeries ( int n ) { for ( int i = 1 ; i <= n ; i ++ ) { int num = i * ( i + 1 ) * ( i + 2 ) / 6 ; System . out . print ( num + " ▁ " ) ; } } public static void main ( String [ ] args ) { int n = 10 ; printSeries ( n ) ; } }