📜  四五角形数

📅  最后修改于: 2021-05-04 14:28:45             🧑  作者: Mango

四角五边形数字是一类数字。它有一个称为Tetracontapentagon的45面多边形。第N个四对五边形数的点数是45个点,所有其他点都围绕着一个公共的共享角并形成图案。
前几个四碳五烯酚的编号是:

查找第N个四对五边形编号的程序

给定数字N ,任务是找到N四对五角形数
例子:

方法:N个四对五角数由下式给出:

  • S面多边形的第N个项= \frac{((S - 2)N^{2} - (S - 4)N)}{2}
  • 因此,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