Find the sum of the first N Centered Octadecagonal Numbers | Function to find the N - th Centered octadecagonal number ; Formula to calculate nth centered octadecagonal number ; Function to find the sum of the first N Centered octadecagonal numbers ; Variable to store the sum ; Iterating through the range 1 to N ; Driver code
def center_octadecagon_num ( n ) : NEW_LINE INDENT return ( 9 * n * n - 9 * n + 1 ) NEW_LINE DEDENT def sum_center_octadecagon_num ( n ) : NEW_LINE INDENT summ = 0 NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT summ += center_octadecagon_num ( i ) NEW_LINE DEDENT return summ NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 3 NEW_LINE print ( sum_center_octadecagon_num ( n ) ) NEW_LINE DEDENT