- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Centered dodecahedral number

The problem statement says to print the N-th centered dodecahedral number for any positive value of N which will be the user input.

A centered dodecahedral number is a number that can be represented in a particular pattern of figure. A dodecahedron is a three-dimensional figure in mathematics which has 12 flat faces. And a centered dodecahedral number is a number which can be represented in the form of a figure with a dot in the centre surrounded by the successive layers of the dodecahedron (12 faced 3-d structure). The successive layers of the dodecahedron says the first layer will have 12 faced 3-D structure surrounding the dot in the centre which is further surrounded by 14 faced 3-D structure and so on.

The first few numbers of the sequence of centered dodecahedral numbers are **1, 33, 155, 427, 909**…..

Each number in the sequence of centered dodecahedral numbers can be represented as a dot in the centre surrounded by the successive layers of the dodecahedron.

In this problem, we will be provided with a positive number N, and our task is to print the N-th centered dodecahedral number corresponding to the value of N.

**Example −**

INPUT : N=2 OUTPUT : 33

**Explanation −** The second number in the sequence of centered dodecahedral numbers is 33 which is represented as a dot in the centre surrounded by a dodecahedron.

INPUT : N=4 OUTPUT : 427

**Explanation −** 427 is the fourth number in the sequence of centered dodecahedral numbers following the particular pattern of the centered dodecahedral number.

Similarly we need to print the N-th number of the sequence of centered dodecahedral numbers in this problem. Let’s see the mathematical relation between every number in the sequence of centred dodecahedral numbers.

## Algorithm

There is a mathematical formula to represent each centered dodecahedral number in the sequence. The way each number in the sequence can be represented in the form of a dot in the centre surrounded by the successive layers of the dodecahedrons, similarly every centered dodecahedral number is of the form mentioned below.

$\mathrm{(centered \: dodecahedral)_n=10(n−1)^3+15(n−1)^2+7(n−1)+1}$

where, n= N-th centered dodecahedral number starting from 1.

Every number of the sequence of centered dodecahedral numbers can be represented in the form of the above mentioned cubic equation. Assume we want the third centered dodecahedral number,

So putting n=3 in the equation, we get

$$\mathrm{= 10(3 − 1)^3 + 15(3 − 1)^2 + 7(3 − 1) + 1}$$

$$\mathrm{= 10*8 + 15*4 + 7*2 + 1}$$

$$\mathrm{= 80 + 60 + 14 + 1 = 155}$$

The third centered dodecahedral number is 155 which we can get from putting n=3 in the cubic equation.

Therefore, we will use this cubic equation in our approach in order to print the N-th centered dodecahedral number for any value of N.

## Approach

The steps to follow to implement the formula of N-th centered dodecahedral number are mentioned below.

We will create a function to get the N-th centered dodecahedral number.

We will make a variable of long long int data type to store the N-th centered dodecahedral number. The long long int data type is taken to store the centered dodecahedral number for larger values of N.

Store the result of the equation $\mathrm{10(N − 1)^3 + 15(N − 1)^2 + 7(N − 1) + 1}$ in the variable.

Return the value stored in the variable which will be the desired output.

The C++ code for the approach −

### Example

//C++ code to print the N-th centered dodecahedral number #include <bits/stdc++.h> using namespace std; //function to calculate the N-th centered dodecahedral number long long int CDn(int N){ //to store the value of centered dodecahedral number corresponding to N long long int num = 10*pow(N-1,3) + 15*pow(N-1,2) + 7*(N-1) + 1 ; return num; //return the N-th centered dodecahedral number } int main(){ int N; N=9; cout<<"The Nth dodecahedral number is "<<CDn(N)<<endl; //calling the function N=19; cout<<"The Nth dodecahedral number is "<<CDn(N)<<endl; return 0; }

### Output

The Nth dodecahedral number is 6137 The Nth dodecahedral number is 63307

**Time Complexity −: O(1)** , we took constant time to calculate the N-th centered dodecahedral number.

**Space Complexity − O(1)** , no extra space is taken in the approach.

## Conclusion

The centered dodecahedral numbers and their representation in the form of figure was discussed in the article. We also learn about the general expression of N-th centered dodecahedral numbers which we used in our approach to solve the problem within constant time and space.

I hope all your queries related to the topic have been cleared after reading this article.