📜  二十面体七边形数

📅  最后修改于: 2021-04-27 20:54:07             🧑  作者: Mango

给定数N ,任务是找到N二十烷七角形数。

例子:

方法:第N个二十烷七角形数由下式给出:

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

下面是上述方法的实现:

C++
// C++ program to find N-th
// icosikaiheptagonal number
#include 
 
using namespace std;
// Function to find the nth
// icosikaiheptagonal Number
int icosikaiheptagonalNum(int n)
{
    return (25 * n * n - 23 * n) / 2;
}
 
// Driver code
int main()
{
    int n = 3;
 
    cout << "3rd icosikaiheptagonal Number is "
         << icosikaiheptagonalNum(n);
 
    return 0;
}


Java
// Java program to find N-th
// icosikaiheptagonal number
class GFG{
 
// Function to find the nth
// icosikaiheptagonal number
static int icosikaiheptagonalNum(int n)
{
    return (25 * n * n - 23 * n) / 2;
}
 
// Driver code
public static void main(String[] args)
{
    int n = 3;
    System.out.print("3rd icosikaiheptagonal Number is " +
                                icosikaiheptagonalNum(n));
}
}
 
// This code is contributed by shubham


Python3
# Python3 program to find N-th
# icosikaiheptagonal number
 
# Function to find the nth
# icosikaiheptagonal Number
def icosikaiheptagonalNum(n):
 
    return (25 * n * n - 23 * n) // 2;
 
# Driver code
n = 3;
print("3rd icosikaiheptagonal Number is ",
                icosikaiheptagonalNum(n));
 
# This code is contributed by Code_Mech


C#
// C# program to find N-th
// icosikaiheptagonal number
using System;
 
class GFG{
 
// Function to find the nth
// icosikaiheptagonal number
static int icosikaiheptagonal(int n)
{
    return (25 * n * n - 23 * n) / 2;
}
 
// Driver code
public static void Main(String[] args)
{
    int n = 3;
     
    Console.Write("3rd icosikaiheptagonal Number is " +
                                icosikaiheptagonal(n));
}
}
 
// This code is contributed by shivanisinghss2110


Javascript


输出:
3rd icosikaiheptagonal Number is 78

参考: http : //www.2dcurves.com/line/linep.html