Program to print triangular number series till n | Java Program to print triangular number series till n ; Function to find triangular number ; For each iteration increase j by 1 and add it into k ; Increasing j by 1 ; Add value of j into k and update k ; Driver function
import java . util . * ; class GFG { static void triangular_series ( int n ) { int i , j = 1 , k = 1 ; for ( i = 1 ; i <= n ; i ++ ) { System . out . printf ( " % d ▁ " , k ) ; j = j + 1 ; k = k + j ; } } public static void main ( String [ ] args ) { int n = 5 ; triangular_series ( n ) ; } }