四角五边形数字是一类数字。它有一个称为Tetracontapentagon的45面多边形。第N个四对五边形数的点数是45个点,所有其他点都围绕着一个公共的共享角并形成图案。
前几个四碳五烯酚的编号是:
1, 45, 132, 262,…
查找第N个四对五边形编号的程序
给定数字N ,任务是找到第N个四对五角形数。
例子:
Input: N = 2
Output: 45
Explanation:
The second Tetracontapentagonol number is 45.
Input: N = 3
Output: 132
方法:第N个四对五角数由下式给出:
- S面多边形的第N个项=
- 因此,45个面的多边形的第N个项由下式给出:
下面是上述方法的实现:
C++
// C++ program for the above approach
#include
using namespace std;
// Function to find the N-th
// Tetracontapentagon Number
int TetracontapentagonNum(int N)
{
return (43 * N * N - 41 * N)
/ 2;
}
// Driver Code
int main()
{
// Given Number
int N = 3;
// Function Call
cout << TetracontapentagonNum(N);
return 0;
}
Java
// Java program for the above approach
class GFG{
// Function to find the nth
// TetracontapentagonNum number
static int TetracontapentagonNum(int N)
{
return (43 * N * N - 41 * N) / 2;
}
// Driver code
public static void main(String[] args)
{
int n = 3;
System.out.print(TetracontapentagonNum(n));
}
}
// This code is contributed by Pratima Pandey
Python3
# Python3 program for the above approach
# Function to find the N-th
# Tetracontapentagon Number
def TetracontapentagonNum(N):
return (43 * N * N - 41 * N) // 2;
# Driver Code
# Given Number
N = 3;
# Function Call
print(TetracontapentagonNum(N));
# This code is contributed by Code_Mech
C#
// C# program for the above approach
using System;
class GFG{
// Function to find the nth
// TetracontapentagonNum number
static int TetracontapentagonNum(int N)
{
return (43 * N * N - 41 * N) / 2;
}
// Driver code
public static void Main()
{
int n = 3;
Console.Write(TetracontapentagonNum(n));
}
}
// This code is contributed by Code_Mech
Javascript
输出:
132