Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Program for Centered Icosahedral Number in C++
Given with a value ‘n’ and the task is to generate the centered Icosahedral number for n and centered Icosahedral series till n and display the results.
What is centered Icosahedral number?
Centered Icosahedral number is a centered number used for representing an icosahedrons(it is a polyhedron figure with 20 faces).
The first few centered icosahedral number series till n = 1000 are −
1, 13, 55, 147, 309, 561, 923
Centered Icosahedral number can be calculated using the formula −
$$(2n+1)\times\frac{5n^{2}+5n+3}{3}$$
Input
number: 20
Output
Centered Icosahedral Number is : 28741
Input
number: 12
Output
Centered Icosahedral Number is : 6525
Algorithm
Start Step 1→ declare function to calculate centered iscosahedral number int calculate(int num) return (2 * num + 1) * (5 * num * num + 5 * num + 3) / 3 Step 2→ In main() Declare int num = 20 Print calculate(num) Stop
Example
#include <bits/stdc++.h>
using namespace std;
//calculate Centered Icosahedral Number
int calculate(int num){
return (2 * num + 1) * (5 * num * num + 5 * num + 3) / 3;
}
int main(){
int num = 20;
cout<<"Centered Icosahedral Number is : "<<calculate(num) << endl;
return 0;
}
Output
If run the above code it will generate the following output −
Centered Icosahedral Number is : 28741
Advertisements
