📜  二十进制对角线数

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

二十碳六烯角数是一类数字。它有29面的多边形,称为icosikaienneagon 。第N个icosikaienneagonal数是29个点,所有其他点都围绕着一个公共的共享角并形成图案。
前几个icosikaienneagonol编号为

找出第N二十烷碳对角线数

给定数N ,任务是找到Nicosikaienneagonal数。
例子:

方法:

  • 在数学中,第N个s面多边形数由以下公式给出:
    \text{Nth term of s sided polygon} = \frac{((s-2)n^2 - (s-4)n)}{2}
  • 因此,第29面多边形的第N个项是

下面是上述方法的实现:

C++
// C++ implementation for
// above approach
 
#include 
using namespace std;
 
// Function to Find the Nth
// icosikaienneagonal Number
int icosikaienneagonalNum(int n)
{
    return (27 * n * n - 25 * n) / 2;
}
 
// Driver Code
int main()
{
    int n = 3;
    cout << icosikaienneagonalNum(n);
 
    return 0;
}


Java
// Java implementation for
// above approach
class GFG{
 
// Function to Find the Nth
// icosikaienneagonal Number
static int icosikaienneagonalNum(int n)
{
    return (27 * n * n - 25 * n) / 2;
}
 
// Driver Code
public static void main(String args[])
{
    int n = 3;
    System.out.print(icosikaienneagonalNum(n));
}
}
 
// This code is contributed by Code_Mech


Python 3
# Python3 implementation for
# above approach
 
# Function to Find the Nth
# icosikaienneagonal Number
def icosikaienneagonalNum(n):
    return (27 * n * n - 25 * n) // 2
 
# Driver Code
 
# Given N
N = 3
print(icosikaienneagonalNum(N))
 
# This code is contributed by Vishal Maurya


C#
// C# implementation for
// above approach
using System;
class GFG{
 
// Function to Find the Nth
// icosikaienneagonal Number
static int icosikaienneagonalNum(int n)
{
    return (27 * n * n - 25 * n) / 2;
}
 
// Driver Code
public static void Main()
{
    int n = 3;
    Console.Write(icosikaienneagonalNum(n));
}
}
 
// This code is contributed by Code_Mech


Javascript


输出:
84