Find the sum of the first Nth Heptadecagonal Number | Function to find the N - th heptadecagonal number ; Formula to calculate nth heptadecagonal number ; Function to find the sum of the first N heptadecagonal numbers ; Variable to store the sum ; Iterating from 1 to N ; Finding the sum ; Driver code
function heptadecagonal_num ( n ) { return ( ( 15 * n * n ) - 13 * n ) / 2 ; } function sum_heptadecagonal_num ( n ) { let summ = 0 ; for ( let i = 1 ; i < n + 1 ; i ++ ) { summ += heptadecagonal_num ( i ) ; } return summ ; } let n = 5 ; document . write ( sum_heptadecagonal_num ( n ) ) ;