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++ program to find the N-th // Icosikaipentagon Number #include <bits/stdc++.h> using namespace std;
// Function to find the N-th // icosikaipentagon Number int icosikaipentagonNum( int N)
{ return (23 * N * N - 21 * N)
/ 2;
} // Driver code int main()
{ int n = 3;
cout << "3rd icosikaipentagon Number is "
<< icosikaipentagonNum(n);
return 0;
} |
// Java program to find N-th // icosikaipentagon number class GFG{
// Function to find the nth // icosikaipentagon number static int icosikaipentagonNum( int N)
{ return ( 23 * N * N - 21 * N) / 2 ;
} // Driver code public static void main(String[] args)
{ int n = 3 ;
System.out.print( "3rd icosikaipentagon Number is " +
icosikaipentagonNum(n));
} } // This code is contributed by shubham |
# Python3 program to find the N-th # icosikaipentagon number # Function to find the N-th # icosikaipentagon number def icosikaipentagonNum(N):
return ( 23 * N * N - 21 * N) / / 2
# Driver code n = 3
print ( "3rd icosikaipentagon Number is " ,
icosikaipentagonNum(n))
# This code is contributed by yatinagg |
// C# program for the above approach using System;
class GFG{
// Finding the nth chiliagon number static int Icosikaipentagon( int n)
{ return (23 * n * n - 21 * n) / 2;
} // Driver code public static void Main()
{ int n = 3;
Console.Write( "3rd Icosikaipentagon Number is = " +
Icosikaipentagon(n));
} } // This code is contributed by shivanisinghss2110 |
<script> // Javascript program to find the N-th // Icosikaipentagon Number // Function to find the N-th // icosikaipentagon Number function icosikaipentagonNum(N)
{ return parseInt((23 * N * N - 21 * N)
/ 2);
} // Driver code let n = 3; document.write( "3rd icosikaipentagon Number is "
+ icosikaipentagonNum(n));
// This code is contributed by rishavmahato348.
</script> |
Output:
3rd icosikaipentagon Number is 72
Time Complexity: O(1)
Auxiliary Space: O(1)
Reference: http://www.2dcurves.com/line/linep.html