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 …
Input: N = 3
1, 6 and 16 are the first three
Centered Pentagonal number.
Input: N = 5
Approach: The idea is to first create a function which would help us to find the centered pentagonal number in a constant time. The implementation of this function has already been discussed in this article. The following steps are followed after creating this function:
- Run a loop starting from 1 to N, to find ith Centered Pentagonal number.
- Add all the above calculated Centered Pentagonal numbers.
- Then, display the sum of N Centered Pentagonalnumbers.
Below is the implementation of the above approach:
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Centered pentagonal number
- Program to check if N is a Centered Pentagonal Number or not
- Find the sum of the first N Centered Dodecagonal Number
- Find the sum of the first Nth Centered Pentadecagonal Number
- Find the sum of the first Nth Centered Hexadecagonal Number
- Find the sum of the first N Centered Octagonal Number
- Find the sum of the first N Centered heptagonal number
- Find the sum of the first Nth Centered Tridecagonal Numbers
- Find the sum of the first N Centered Decagonal Numbers
- Find the sum of the first N Centered Octadecagonal Numbers
- Find all numbers up to N which are both Pentagonal and Hexagonal
- n'th Pentagonal Number
- Program to check if N is a Pentagonal Number
- Pentagonal Pyramidal Number
- Second Pentagonal numbers
- Centered cube number
- Centered Dodecagonal Number
- Centered hexagonal number
- Program for centered nonagonal number
- Centered Octadecagonal Number
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.