Icosikaipentagon Number
Last Updated :
05 Apr, 2021
Given a number N, the task is to find Nth icosikaipentagon number.
An icosikaipentagon number is class of figurate number. It has 25- sided polygon called icosikaipentagon. The N-th icosikaipentagon number count’s the 25 number of dots and all others dots are surrounding with a common sharing corner and make a pattern. The first few icosikaipentagonol numbers are 1, 25, 72, 142 …
Examples:
Input: N = 2
Output: 25
Explanation:
The second icosikaipentagonol number is 25.
Input: N = 3
Output: 72
Approach: The N-th icosikaipentagon number is given by the formula:
- N-th term of S sided polygon =
- Therefore N-th term of 25 sided polygon is given by:
Below is the implementation of the above approach:
C++
#include <bits/stdc++.h>
using namespace std;
int icosikaipentagonNum( int N)
{
return (23 * N * N - 21 * N)
/ 2;
}
int main()
{
int n = 3;
cout << "3rd icosikaipentagon Number is "
<< icosikaipentagonNum(n);
return 0;
}
|
Java
class GFG{
static int icosikaipentagonNum( int N)
{
return ( 23 * N * N - 21 * N) / 2 ;
}
public static void main(String[] args)
{
int n = 3 ;
System.out.print( "3rd icosikaipentagon Number is " +
icosikaipentagonNum(n));
}
}
|
Python3
def icosikaipentagonNum(N):
return ( 23 * N * N - 21 * N) / / 2
n = 3
print ( "3rd icosikaipentagon Number is " ,
icosikaipentagonNum(n))
|
C#
using System;
class GFG{
static int Icosikaipentagon( int n)
{
return (23 * n * n - 21 * n) / 2;
}
public static void Main()
{
int n = 3;
Console.Write( "3rd Icosikaipentagon Number is = " +
Icosikaipentagon(n));
}
}
|
Javascript
<script>
function icosikaipentagonNum(N)
{
return parseInt((23 * N * N - 21 * N)
/ 2);
}
let n = 3;
document.write( "3rd icosikaipentagon Number is "
+ icosikaipentagonNum(n));
</script>
|
Output: 3rd icosikaipentagon Number is 72
Time Complexity: O(1)
Auxiliary Space: O(1)
Reference: http://www.2dcurves.com/line/linep.html
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...