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 Code
< ? php function triangular_series ( $ n ) { $ i ; $ j = 1 ; $ k = 1 ; for ( $ i = 1 ; $ i <= $ n ; $ i ++ ) { echo ( " ▁ " . $ k . " ▁ " ) ; $ j = $ j + 1 ; $ k = $ k + $ j ; } } $ n = 5 ; triangular_series ( $ n ) ; ? >