📜  Triacontakaihenagonal number

📅  最后修改于: 2021-04-30 02:27:46             🧑  作者: Mango

Triacontakaihenagonagonal数字是一类数字。它具有31面的多边形,称为triacontakaihenagon 。第N个三方正七角点数是31个点的数量,所有其他点都被一个公共的共享角包围并形成一个图案。
前三个三苯环己烯醇的编号是:

检查N是否为triacontakaihenagonol号

给定数N ,任务是找到N三二十碳六烯对角数。
例子:

方法:在数学中,第N个triacontakaihenagonagonal数由下式给出:

  • 侧多边形的第N个项= \frac{((s-2)n^2 - (s-4)n)}{2}
  • 因此,第31个面的多边形的第N个项是

下面是上述方法的实现:

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


Java
// Java implementation for the
// above approach
import java.util.*;
 
class GFG{
 
// Function to find the Nth
// triacontakaihenagonal Number
static int triacontakaihenagonalNum(int n)
{
    return (29 * n * n - 27 * n) / 2;
}
 
// Driver Code
public static void main (String[] args)
{
     
    // Given number
    int n = 3;
 
    // Function call
    System.out.print(triacontakaihenagonalNum(n));
}
}
 
// This code is contributed by Ritik Bansal


Python3
# Python3 implementation for
# above approach
 
# Function to find the Nth
# triacontakaihenagonal Number
def triacontakaihenagonalNum(n):
 
    return (29 * n * n - 27 * n) // 2;
 
# Driver Code
n = 3;
print(triacontakaihenagonalNum(n));
 
# This code is contributed by Code_Mech


C#
// C# implementation for the
// above approach
using System;
  
class GFG{
  
// Function to find the Nth
// triacontakaihenagonal Number
static int triacontakaihenagonalNum(int n)
{
    return (29 * n * n - 27 * n) / 2;
}
  
// Driver Code
public static void Main (string[] args)
{
      
    // Given number
    int n = 3;
  
    // Function call
    Console.Write(triacontakaihenagonalNum(n));
}
}
  
// This code is contributed by rock_cool


Javascript


输出:
90