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
function Icosagonal_num ( n ) { return ( 18 * n * n - 16 * n ) / 2 ; } function sum_Icosagonal_num ( n ) { let summ = 0 ; for ( let i = 1 ; i <= n ; i ++ ) { summ += Icosagonal_num ( i ) ; } return summ ; } let n = 5 ; document . write ( sum_Icosagonal_num ( n ) ) ;