Find the sum of the first N Centered Decagonal Numbers | C ++ program to find the sum of the first N centred decagonal number ; 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
#include <bits/stdc++.h> NEW_LINE using namespace std ; int Centered_decagonal_num ( int n ) { return ( 5 * n * n - 5 * n + 1 ) ; } int sum_Centered_decagonal_num ( int n ) { int summ = 0 ; for ( int i = 1 ; i < n + 1 ; i ++ ) { summ += Centered_decagonal_num ( i ) ; } return summ ; } int main ( ) { int n = 5 ; cout << ( sum_Centered_decagonal_num ( n ) ) ; return 0 ; }