Open In App

Icosikaienneagonal Number

An icosikaienneagonal number is a class of figurate numbers. It has 29 – sided polygon called icosikaienneagon. The N-th icosikaienneagonal number count’s the 29 number of dots and all other dots are surrounding with a common sharing corner and make a pattern.
The first few icosikaienneagonol numbers are 
 

1, 29, 84, 166 … 
 




 

Find the Nth icosikaienneagonal number


Given a number N, the task is to find Nth icosikaienneagonal number.
Examples: 
 



Input: N = 2 
Output: 29 
Explanation: 
The second icosikaienneagonol number is 29. 
Input: N = 3 
Output: 84 
 


 


Approach: 
 


Below is the implementation of the above approach:
 

// C++ implementation for
// above approach
 
#include <iostream>
using namespace std;
 
// Function to Find the Nth
// icosikaienneagonal Number
int icosikaienneagonalNum(int n)
{
    return (27 * n * n - 25 * n) / 2;
}
 
// Driver Code
int main()
{
    int n = 3;
    cout << icosikaienneagonalNum(n);
 
    return 0;
}

                    
// Java implementation for
// above approach
class GFG{
 
// Function to Find the Nth
// icosikaienneagonal Number
static int icosikaienneagonalNum(int n)
{
    return (27 * n * n - 25 * n) / 2;
}
 
// Driver Code
public static void main(String args[])
{
    int n = 3;
    System.out.print(icosikaienneagonalNum(n));
}
}
 
// This code is contributed by Code_Mech

                    
# Python3 implementation for
# above approach
 
# Function to Find the Nth
# icosikaienneagonal Number
def icosikaienneagonalNum(n):
    return (27 * n * n - 25 * n) // 2
 
# Driver Code
 
# Given N
N = 3
print(icosikaienneagonalNum(N))
 
# This code is contributed by Vishal Maurya

                    
// C# implementation for
// above approach
using System;
class GFG{
 
// Function to Find the Nth
// icosikaienneagonal Number
static int icosikaienneagonalNum(int n)
{
    return (27 * n * n - 25 * n) / 2;
}
 
// Driver Code
public static void Main()
{
    int n = 3;
    Console.Write(icosikaienneagonalNum(n));
}
}
 
// This code is contributed by Code_Mech

                    
<script>
// Javascript implementation for
// above approach
 
 
    // Function to Find the Nth
    // icosikaienneagonal Number
    function icosikaienneagonalNum( n) {
        return (27 * n * n - 25 * n) / 2;
    }
 
    // Driver Code
      
    let n = 3;
    document.write(icosikaienneagonalNum(n));
 
// This code is contributed by Rajput-Ji
</script>

                    

Output: 
84

 

Time Complexity: O(1)

Auxiliary Space: O(1)


Article Tags :