Find the sum of the first N Centered Decagonal Numbers | Function to find the N - th centred decagonal number ; Formula to calculate nth centered_decagonal number & return it into main function . ; Function to find the sum of the first N centered decagonal numbers ; Variable to store the sum ; Iterating through the range ; Driver code ; Display first Nth centered_decagonal number
function Centered_decagonal_num ( n ) { return ( 5 * n * n - 5 * n + 1 ) ; } function sum_Centered_decagonal_num ( n ) { let summ = 0 ; for ( let i = 1 ; i < n + 1 ; i ++ ) { summ += Centered_decagonal_num ( i ) ; } return summ ; } let n = 5 ; document . write ( sum_Centered_decagonal_num ( n ) ) ;