Program for Centered Icosahedral Number

We are given a number n, we need to find n-th centered Icosahedral number.

Description: A centered icosahedral number is a centered figurate number that represents an icosahedron.

The first few centered icosahedral number series are :
1, 13, 55, 147, 309, 561, 923, 1415, 2057, 2869, 3871, 5083, 6525, 8217……………….

Mathematical Formula for nth Centered icosahedral number:

 \begin{math}CI_{n} = \frac{(2n+1)(5n^2+5n+3)}{3} 

Examples :



Input : n = 4
Output : 309

Input : n = 12
Output : 6525

Below is the implementation of the above formula

C++

filter_none

edit
close

play_arrow

link
brightness_4
code

// C++ Program to find nth
// Centered icosahedral number
#include <bits/stdc++.h>
using namespace std;
  
// Function to find
// Centered icosahedral number
int centeredIcosahedralNum(int n)
{
    // Formula to calculate nth
    // Centered icosahedral number
    // and return it into main function.
    return (2 * n + 1) * (5 * n * n + 5 * n + 3) / 3;
}
  
// Driver Code
int main()
{
    int n = 10;
    cout << centeredIcosahedralNum(n) << endl;
  
    n = 12;
    cout << centeredIcosahedralNum(n) << endl;
  
    return 0;
}

chevron_right


Java

filter_none

edit
close

play_arrow

link
brightness_4
code

// Java Program to find nth
// Centered icosahedral number
// Java Program to find nth Centered
// icosahedral number
  
import java.io.*;
  
class GFG {
      
    // Function to find Centered
    // icosahedral number
    static int centeredIcosahedralNum(int n)
    {
          
        // Formula to calculate nth Centered 
        // icosahedral number and return it
        // into main function.
        return (2 * n + 1) * (5 * n * n +
                             5 * n + 3) / 3;
    }
      
    // Driver Code
    public static void main (String[] args)
    {
        int n = 10;
        System.out.println(
                   centeredIcosahedralNum(n));
      
        n = 12;
        System.out.println( 
                   centeredIcosahedralNum(n));
    }
}
  
// This code is contributed by anuj_67.

chevron_right


Python3

filter_none

edit
close

play_arrow

link
brightness_4
code

# Python program to find nth 
# Centered icosahedral number
  
# Function to calculate
# Centered icosahedral number
  
def centeredIcosahedralNum(n):
  
    # Formula to calculate nth
    # Centered icosahedral number
    return ((2 * n + 1) * 
            (5 * n * n + 5 * n + 3) // 3)
  
# Driver Code
n = 10
print(centeredIcosahedralNum(n))
  
n = 12
print(centeredIcosahedralNum(n))
                      
# This code is contributed by ajit.                 

chevron_right


C#

filter_none

edit
close

play_arrow

link
brightness_4
code

// C# Program to find nth
// Centered icosahedral number
// Java Program to find nth Centered
// icosahedral number
  
using System;
  
class GFG {
      
    // Function to find Centered
    // icosahedral number
    static int centeredIcosahedralNum(int n)
    {
          
        // Formula to calculate nth Centered 
        // icosahedral number and return it
        // into main function.
        return (2 * n + 1) * (5 * n * n +
                            5 * n + 3) / 3;
    }
      
    // Driver Code
    public static void Main ()
    {
        int n = 10;
        Console.WriteLine(
                centeredIcosahedralNum(n));
      
        n = 12;
        Console.WriteLine( 
                centeredIcosahedralNum(n));
    }
}
  
// This code is contributed by anuj_67.

chevron_right


PHP

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
// PHP Program to find nth
// Centered icosahedral number
  
// Function to find
// Centered icosahedral number
function centeredIcosahedralNum($n)
{
    // Formula to calculate nth
    // Centered icosahedral number
    // and return it into main function.
    return (2 * $n + 1) * (5 *
            $n * $n + 5 * $n + 3) / 3;
}
  
// Driver Code
$n = 10;
echo centeredIcosahedralNum($n),"\n";
  
$n = 12;
echo centeredIcosahedralNum($n),"\n";
  
// This code is contributed by m_kit
?>

chevron_right


Output :

3871
6525

Reference:
https://en.wikipedia.org/wiki/Centered_icosahedral_number



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.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.



Improved By : jit_t, vt_m