Find the sum of the first Nth Icosagonal Numbers | Function to calculate the N - th Icosagonal number ; Formula to calculate nth Icosagonal number & return it ; Function to find the sum of the first N Icosagonal numbers ; Variable to store the sum ; Loop to iterate through the first N values and find the sum of first N Icosagonal numbers ; function to get the Icosagonal_num ; Driver Code ; Display the sum of first N Icosagonal number
def Icosagonal_num ( n ) : NEW_LINE INDENT return ( 18 * n * n - 16 * n ) // 2 NEW_LINE DEDENT def sum_Icosagonal_num ( n ) : NEW_LINE INDENT summ = 0 NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT summ += Icosagonal_num ( i ) NEW_LINE DEDENT return summ NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 5 NEW_LINE print ( sum_Icosagonal_num ( n ) ) NEW_LINE DEDENT