Icosikaienneagonal Number
Last Updated :
16 Jul, 2021
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:
- In mathematics, the N-th s-sided polygon number is given by the formula:
- Therefore Nth term of 29 sided polygon is
Below is the implementation of the above approach:
C++
#include <iostream>
using namespace std;
int icosikaienneagonalNum( int n)
{
return (27 * n * n - 25 * n) / 2;
}
int main()
{
int n = 3;
cout << icosikaienneagonalNum(n);
return 0;
}
|
Java
class GFG{
static int icosikaienneagonalNum( int n)
{
return ( 27 * n * n - 25 * n) / 2 ;
}
public static void main(String args[])
{
int n = 3 ;
System.out.print(icosikaienneagonalNum(n));
}
}
|
Python 3
def icosikaienneagonalNum(n):
return ( 27 * n * n - 25 * n) / / 2
N = 3
print (icosikaienneagonalNum(N))
|
C#
using System;
class GFG{
static int icosikaienneagonalNum( int n)
{
return (27 * n * n - 25 * n) / 2;
}
public static void Main()
{
int n = 3;
Console.Write(icosikaienneagonalNum(n));
}
}
|
Javascript
<script>
function icosikaienneagonalNum( n) {
return (27 * n * n - 25 * n) / 2;
}
let n = 3;
document.write(icosikaienneagonalNum(n));
</script>
|
Time Complexity: O(1)
Auxiliary Space: O(1)
Share your thoughts in the comments
Please Login to comment...