Find the sum of the first Nth Icosagonal Numbers | C ++ program to find the sum of the first N icosagonal number ; 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
#include <bits/stdc++.h> NEW_LINE using namespace std ; int Icosagonal_num ( int n ) { return ( 18 * n * n - 16 * n ) / 2 ; } int sum_Icosagonal_num ( int n ) { int summ = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { summ += Icosagonal_num ( i ) ; } return summ ; } int main ( ) { int n = 5 ; cout << sum_Icosagonal_num ( n ) << endl ; }