Program to print pentatope numbers upto Nth term | Function to generate nth tetrahedral number ; Function to print pentatope number series upto nth term . ; Initialize prev as 0. It store the sum of all previously generated pentatope numbers ; Loop to print pentatope series ; Find ith tetrahedral number ; Add ith tetrahedral number to sum of all previously generated tetrahedral number to get ith pentatope number ; Update sum of all previously generated tetrahedral number ; Driver code ; Function call to print pentatope number series
< ? php function findTetrahedralNumber ( $ n ) { return ( ( $ n * ( $ n + 1 ) * ( $ n + 2 ) ) / 6 ) ; } function printSeries ( $ n ) { $ prev = 0 ; $ curr ; for ( $ i = 1 ; $ i <= $ n ; $ i ++ ) { $ curr = findTetrahedralNumber ( $ i ) ; $ curr = $ curr + $ prev ; echo ( $ curr . " " ) ; $ prev = $ curr ; } } $ n = 10 ; printSeries ( $ n ) ; ? >