Find the sum of the first N Centered Decagonal Numbers Last Updated : 19 Sep, 2022 Comments Improve Suggest changes Like Article Like Report Given a number N, the task is to find the sum of the first N Centered Decagonal Numbers. The first few Centered decagonal numbers are 1, 11, 31, 61, 101, 151 ... Examples: Input: N = 3 Output: 43 Explanation: 1, 11 and 31 are the first three Centered decagonal numbers.Input: N = 5 Output: 205 Approach: Initially, we need to create a function which will help us to calculate the Nth Centered decagonal number.Now, run a loop starting from 1 to N, to find the ith Centered decagonal number.Add all the above calculated Centered decagonal numbers.Finally, display the sum of 1st N Centered decagonal numbers. Below is the implementation of the above approach: C++ // C++ program to find the sum of the // first N centered decagonal number #include <bits/stdc++.h> using namespace std; // Function to find the N-th // centered decagonal number int Centered_decagonal_num(int n) { // Formula to calculate nth // centered_decagonal number // & return it into main function. return (5 * n * n - 5 * n + 1); } // Function to find the sum of // the first N centered decagonal // numbers int sum_Centered_decagonal_num(int n) { // Variable to store // the sum int summ = 0; // Iterating through the range for(int i = 1; i < n + 1; i++) { summ += Centered_decagonal_num(i); } return summ; } // Driver code int main() { int n = 5; // Display first Nth // centered_decagonal number cout << (sum_Centered_decagonal_num(n)); return 0; } // This code is contributed by PrinciRaj1992 Java // Java program to find the sum of the // first N centered decagonal number class GFG { // Function to find the N-th // centered decagonal number static int Centered_decagonal_num(int n) { // Formula to calculate nth // centered_decagonal number // & return it into main function. return (5 * n * n - 5 * n + 1); } // Function to find the sum of // the first N centered decagonal // numbers static int sum_Centered_decagonal_num(int n) { // Variable to store // the sum int summ = 0; // Iterating through the range for(int i = 1; i < n + 1; i++) { summ += Centered_decagonal_num(i); } return summ; } // Driver code public static void main(String[] args) { int n = 5; // Display first Nth // centered_decagonal number System.out.println(sum_Centered_decagonal_num(n)); } } // This code is contributed by sapnasingh4991 Python3 # Python3 program to find the sum of # the first N centered # decagonal number # Function to find the N-th # centered decagonal number def Centered_decagonal_num(n): # Formula to calculate # nth Centered_decagonal # number & return it # into main function. return (5 * n * n - 5 * n + 1) # Function to find the # sum of the first N # Centered decagonal # numbers def sum_Centered_decagonal_num(n) : # Variable to store # the sum summ = 0 # Iterating through the range for i in range(1, n + 1): summ += Centered_decagonal_num(i) return summ # Driver code if __name__ == '__main__' : n = 5 # display first Nth # Centered_decagonal number print(sum_Centered_decagonal_num(n)) C# // C# program to find the sum of the // first N centered decagonal number using System; class GFG { // Function to find the N-th // centered decagonal number static int Centered_decagonal_num(int n) { // Formula to calculate nth // centered_decagonal number // & return it into main function. return (5 * n * n - 5 * n + 1); } // Function to find the sum of // the first N centered decagonal // numbers static int sum_Centered_decagonal_num(int n) { // Variable to store // the sum int summ = 0; // Iterating through the range for(int i = 1; i < n + 1; i++) { summ += Centered_decagonal_num(i); } return summ; } // Driver code public static void Main(String[] args) { int n = 5; // Display first Nth // centered_decagonal number Console.WriteLine(sum_Centered_decagonal_num(n)); } } // This code is contributed by sapnasingh4991 JavaScript <script> // Javascript program to find the sum of the // first N centered decagonal number // Function to find the N-th // centered decagonal number function Centered_decagonal_num(n) { // Formula to calculate nth // centered_decagonal number // & return it into main function. return (5 * n * n - 5 * n + 1); } // Function to find the sum of // the first N centered decagonal // numbers function sum_Centered_decagonal_num(n) { // Variable to store // the sum let summ = 0; // Iterating through the range for(let i = 1; i < n + 1; i++) { summ += Centered_decagonal_num(i); } return summ; } let n = 5; // Display first Nth // centered_decagonal number document.write(sum_Centered_decagonal_num(n)); </script> Output: 205 Time Complexity: O(N).Auxiliary Space: O(1) as it is using constant variables Comment More infoAdvertise with us Next Article Find the sum of the first N Centered Decagonal Numbers S SHUBHAMSINGH10 Follow Improve Article Tags : Mathematical DSA Practice Tags : Mathematical Similar Reads Find the sum of the first N Centered Dodecagonal Number Given a number N, the task is to find the sum of first N Centered Dodecagonal Number. The first few Centered Dodecagonal Numbers are 1, 13, 37, 73, 121, 181 ... Examples: Input: N = 3 Output: 51 Explanation: 1, 13 and 37 are the first three centered Dodecagonal number.Input: N = 5 Output: 245 Approa 4 min read Find the sum of the first N Dodecagonal Numbers Given a number N the task is to find the sum of first N Dodecagonal Number. The first few dodecagonal numbers are 1, 12, 33, 64, 105, 156, 217 ... Examples: Input: N = 3 Output: 46 Explanation: 1, 12 and 33 are the first three Dodecagonal numbers Input: N = 5 Output: 215 Approach: Initially, we need 4 min read Find the sum of the first N Centered Octagonal Number Given a number N, the task is to find the sum of the first N Centered Octagonal Numbers. The first few Centered Octagonal numbers are 1, 9, 25, 49, 81, 121, 169, 225, 289, 361 ... Examples: Input: N = 3 Output: 35 Explanation: 1, 9 and 25 are the first three Centered Octagonal numbers. Input: N = 5 4 min read Find the sum of the first N Centered Pentagonal Number Given a number N, the task is to find the sum of first N Centered Pentagonal Numbers. The first few Centered Pentagonal Number are 1, 6, 16, 31, 51, 76, 106 ⦠Examples: Input: N = 3 Output: 23 Explanation: 1, 6 and 16 are the first three Centered Pentagonal number.Input: N = 5 Output: 105 Approach: 5 min read Find the sum of the first N Centered Octadecagonal Numbers Given a number N, the task is to find the sum of first N Centered Octadecagonal numbers.Examples: Input: N = 3 Output: 75 Explanation: 1, 19 and 55 are the first three centered octadecagonal numbers.Input: N = 10 Output: 298 Approach: Initially, we need to create a function which will help us to cal 4 min read Find the sum of the first Nth Centered Tridecagonal Numbers Given a number N, the task is to find the sum of first N Centered tridecagonal number. A Centered tridecagonal number represents a dot at the center and other dots surrounding the center dot in the successive tridecagonal(13 sided polygon) layer. The first few Centered tridecagonal numbers are 1, 14 5 min read Find the sum of the first Nth Centered Hexadecagonal Number Given a number N, the task is to find the sum of the first N Centered Hexadecagonal Number. The first few Centered Hexadecagonal Numbers are 1, 17, 49, 97, 161, 241 ... Examples: Input: N = 3 Output: 67 Explanation: 1, 17 and 49 are the first three centered Hexadecagonal numbers.Input: N = 5 Output: 5 min read Find the sum of the first Nth Centered Pentadecagonal Number Given a number N the task is to find the sum of the first N Centered Pentadecagonal Number. The first few Centered Pentadecagonal Numbers are 1, 16, 46, 91, 151, 226, 316 ... Examples: Input: N = 3 Output: 63 Explanation: 1, 16 and 46 are the first three centered pentadecagonal numbers. Input: N = 5 4 min read Program to check if N is a Centered Decagonal Number Given an integer N, the task is to check if N is a Centered Decagonal Number or not. If the number N is a Centered Decagonal Number then print "Yes" else print "No". Centered Decagonal Number is centered figurative number that represents a decagon with dot in center and all other dot surrounding it 4 min read Find the sum of the first Nth Heptadecagonal Number Given a number N, the task is to find the sum of first N Heptadecagonal Numbers. The first few heptadecagonal numbers are 1, 17, 48, 94, 155, 231 ... Examples: Input: N = 3 Output: 66 Explanation: 1, 17 and 48 are the first three heptadecagonal numbers.Input: N = 6 Output: 546 Approach: Initially, w 4 min read Like