📜  余弦数

📅  最后修改于: 2021-04-29 06:26:11             🧑  作者: Mango

给定数字n,任务是找到第n个二十进制正弦数(Isdn)。
多边形有很多多边形,取决于它们的角数系列。在数学中,有许多个gonal数,而二十进制正角数是其中之一,并且这些数具有22面的多边形(icosidigon)。二十进制数属于图形数类。它们具有一个共同的点点,而其他点图案则按第n个嵌套二十进制图案排列。
例子 :

二十面体数22

第n个余弦正弦数的公式:

\begin{math}  Isd_{n}=((20n^2)-18n)/2 \end{math}

C++
// C++ program to find nth Icosidigonal
// number
#include 
using namespace std;
 
// Function to calculate Icosidigonal number
int icosidigonal_num(long int n)
{
    // Formula for finding
    // nth Icosidigonal number
    return (20 * n * n - 18 * n) / 2;
}
 
// Driver function
int main()
{
    long int n = 4;
    cout << n << "th Icosidigonal number :" << icosidigonal_num(n);
    cout << endl;
    n = 8;
    cout << n << "th Icosidigonal number:" << icosidigonal_num(n);
    return 0;
}


Java
// Java program to find nth
// Icosidigonal number
import java.io.*;
 
class GFG
{
     
    // Function to calculate
    // Icosidigonal number
    static int icosidigonal_num(int n)
    {
         
    // Formula for finding
    // nth Icosidigonal number
     
    return (20 * n * n - 18 * n) / 2;
    }
 
// Driver Code
public static void main (String[] args)
{
 
    int n = 4;
    System.out.print (n + "th Icosidigonal number :");
    System.out.println (icosidigonal_num(n));
 
    n = 8;
    System.out.print (n + "th Icosidigonal number :");
    System.out.println (icosidigonal_num(n));
}
}
 
// This code is contributed by ajit


Python 3
# python 3 program to find
# nth Icosidigonal number
 
# Function to calculate
# Icosidigonal number
def icosidigonal_num(n) :
     
    # Formula for finding
    # nth Icosidigonal number
    return (20 * n * n -
            18 * n) // 2
 
# Driver Code
if __name__ == '__main__' :
         
    n = 4
    print(n,"th Icosidigonal " +
                    "number : ",
            icosidigonal_num(n))
    n = 8
    print(n,"th Icosidigonal " +
                    "number : ",
            icosidigonal_num(n))
     
# This code is contributed m_kit


C#
// C# program to find nth
// Icosidigonal number
using System;
 
class GFG
{
     
    // Function to calculate
    // Icosidigonal number
    static int icosidigonal_num(int n)
    {
         
    // Formula for finding
    // nth Icosidigonal number
    return (20 * n * n -
            18 * n) / 2;
    }
 
// Driver Code
static public void Main ()
{
int n = 4;
Console.Write(n + "th Icosidigonal " +
                          "number :");
Console.WriteLine(icosidigonal_num(n));
 
n = 8;
Console.Write (n + "th Icosidigonal "+
                          "number :");
Console.WriteLine(icosidigonal_num(n));
}
}
 
// This code is contributed by ajit


PHP


Javascript


输出 :

4th Icosidigonal number :124
8th Icosidigonal number:568

参考:https://en.wikipedia.org/wiki/Polygonal_number