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
def findTetrahedralNumber ( n ) : NEW_LINE INDENT return ( int ( ( n * ( n + 1 ) * ( n + 2 ) ) / 6 ) ) NEW_LINE DEDENT def printSeries ( n ) : NEW_LINE INDENT prev = 0 NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT curr = findTetrahedralNumber ( i ) NEW_LINE curr = curr + prev ; NEW_LINE print ( curr , end = ' ▁ ' ) NEW_LINE prev = curr NEW_LINE DEDENT DEDENT n = 10 NEW_LINE printSeries ( n ) NEW_LINE