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
function center_octadecagon_num ( n ) { return ( 9 * n * n - 9 * n + 1 ) ; } function sum_center_octadecagon_num ( n ) { let summ = 0 ; for ( let i = 1 ; i < n + 1 ; i ++ ) { summ += center_octadecagon_num ( i ) ; } return summ ; } let n = 3 ; document . write ( sum_center_octadecagon_num ( n ) ) ;