Find the sum of the first Nth Centered Tridecagonal 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 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, 40, 79 ... Examples: Input: N = 3 Output: 55 Explanation: 1, 14 and 40 are the first three Centered tridecagonal number. 1 + 14 + 40 = 55. Input: N = 5 Output: 265 Approach: Initially, we need to create a function which will help us to calculate the Nth Centered tridecagonal number.Now, Run a loop starting from 1 to N, and find the Centered tridecagonal numbers in this range.Add all the above calculated Centered tridecagonal numbers.Finally, display the sum of the first N Centered tridecagonal numbers. Below is the implementation of the above approach: C++ // C++ program to find the sum of // the first Nth centered // tridecagonal number #include<bits/stdc++.h> using namespace std; // Function to calculate the // N-th centered tridecagonal // number int Centered_tridecagonal_num(int n) { // Formula to calculate // Nth centered tridecagonal // number & return it return (13 * n * (n - 1) + 2) / 2; } // Function to find the sum // of the first N centered // tridecagonal numbers int sum_Centered_tridecagonal_num(int n) { // Variable to store // the sum int summ = 0; // Loop to iterate and find the // sum of first N centered // tridecagonal numbers for(int i = 1; i <= n; i++) { summ += Centered_tridecagonal_num(i); } return summ ; } // Driver code int main() { int n = 5; cout << sum_Centered_tridecagonal_num(n) << endl; return 0; } // This code is contributed by rutvik_56 Java // Java program to find the sum of // the first Nth centered // tridecagonal number class GFG{ // Function to calculate the // N-th centered tridecagonal // number public static int Centered_tridecagonal_num(int n) { // Formula to calculate // Nth centered tridecagonal // number & return it return (13 * n * (n - 1) + 2) / 2; } // Function to find the sum // of the first N centered // tridecagonal numbers public static int sum_Centered_tridecagonal_num(int n) { // Variable to store // the sum int summ = 0; // Loop to iterate and find the // sum of first N centered // tridecagonal numbers for(int i = 1; i <= n; i++) { summ += Centered_tridecagonal_num(i); } return summ ; } // Driver code public static void main(String[] args) { int n = 5; System.out.println(sum_Centered_tridecagonal_num(n)); } } // This code is contributed by divyeshrabadiya07 Python3 # Program to find the sum of # the first Nth # Centered_tridecagonal number # Function to calculate the # N-th Centered tridecagonal # number def Centered_tridecagonal_num(n): # Formula to calculate # Nth Centered tridecagonal # number & return it return (13 * n * (n - 1) + 2) // 2 # Function to find the sum # of the first N # Centered tridecagonal # numbers def sum_Centered_tridecagonal_num(n) : # Variable to store # the sum summ = 0 # Loop to iterate and find the # sum of first N Centered # tridecagonal numbers for i in range(1, n + 1): summ += Centered_tridecagonal_num(i) return summ # Driver Code if __name__ == '__main__' : n = 5 print(sum_Centered_tridecagonal_num(n)) C# // C# program to find the sum of // the first Nth centered // tridecagonal number using System; class GFG{ // Function to calculate the // N-th centered tridecagonal // number public static int Centered_tridecagonal_num(int n) { // Formula to calculate // Nth centered tridecagonal // number & return it return (13 * n * (n - 1) + 2) / 2; } // Function to find the sum // of the first N centered // tridecagonal numbers public static int sum_Centered_tridecagonal_num(int n) { // Variable to store // the sum int summ = 0; // Loop to iterate and find the // sum of first N centered // tridecagonal numbers for(int i = 1; i <= n; i++) { summ += Centered_tridecagonal_num(i); } return summ; } // Driver code public static void Main() { int n = 5; Console.WriteLine(sum_Centered_tridecagonal_num(n)); } } // This code is contributed by Code_Mech JavaScript <script> // Javascript program to find the sum of // the first Nth centered // tridecagonal number // Function to calculate the // N-th centered tridecagonal // number function Centered_tridecagonal_num(n) { // Formula to calculate // Nth centered tridecagonal // number & return it return (13 * n * (n - 1) + 2) / 2; } // Function to find the sum // of the first N centered // tridecagonal numbers function sum_Centered_tridecagonal_num(n) { // Variable to store // the sum let summ = 0; // Loop to iterate and find the // sum of first N centered // tridecagonal numbers for(let i = 1; i <= n; i++) { summ += Centered_tridecagonal_num(i); } return summ ; } let n = 5; document.write(sum_Centered_tridecagonal_num(n)); // This code is contributed by divyesh072019. </script> Output: 265 Time complexity: O(N).Auxiliary Space: O(1) as it is using constant space for variables Comment More infoAdvertise with us Next Article Find the sum of the first Nth Centered Tridecagonal Numbers S SHUBHAMSINGH10 Follow Improve Article Tags : Mathematical DSA Practice Tags : Mathematical Similar Reads Find the sum of the first N Centered Decagonal Numbers 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 Approa 5 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 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 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 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 Like