热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

icositrigonical号

icositrigonical号原文:https://www.

icositrigonical 号

原文:https://www.geeksforgeeks.org/icositrigonal-number/

给定一个数字 N ,任务是找到 N T5【Icositrigonal】号。

一个整数是一类整数。它有一个 23 边的多边形,叫做 Icositrigon。第 N 个 Icositrigonal 数字计数是 23 个点的数量,所有其他点都被一个公共的共享角包围并形成一个图案。前几个 Icositrigonol 数字是 1、23、66、130、215、321、448……

例:

输入: N = 2
输出: 23
解释:
第二个 Icositrigonol 数是 66。
输入: N = 6
输出: 321

方法:第 N 个 Icositrigonal 数由公式给出:

以下是上述方法的实现:

C++

// C++ program to find nth
// Icositrigonal number
#include
using namespace std;
// Function to find N-th
// Icositrigonal number
int Icositrigonal_num(int n)
{
    // Formula to calculate nth
    // Icositrigonal number
    return (21 * n * n - 19 * n) / 2;
}
// Driver Code
int main()
{
    int n = 3;
    cout <    n = 10;
    cout <    return 0;
}

Java 语言(一种计算机语言,尤用于创建网站)

// Java program to find nth
// Icositrigonal number
class GFG{
// Function to find N-th
// Icositrigonal number   
static int IcositrigonalNum(int n)
{
    // Formula to calculate nth
    // Icositrigonal number
    return (21 * n * n - 19 * n) / 2;
}
// Driver code
public static void main(String[] args)
{
    int n = 3;
    System.out.print(IcositrigonalNum(n) + "\n");
    n = 10;
    System.out.print(IcositrigonalNum(n));
}
}
// This code is contributed by spp____

Python 3

# Python3 program to find nth
# Icositrigonal number
# Function to find N-th
# Icositrigonal number
def IcositrigonalNum(n):
    # Formula to calculate nth
    # Icositrigonal number
    return (21 * n * n - 19 * n) / 2;
# Driver code
n = 3
print(IcositrigonalNum(n))
n = 10
print(IcositrigonalNum(n))
# This code is contributed by spp____

C

// C# program to find nth
// Icositrigonal number
using System;
class GFG{
// Function to find N-th
// Icositrigonal number    
static int IcositrigonalNum(int n)
{
    // Formula to calculate nth
    // Icositrigonal number
    return (21 * n * n - 19 * n) / 2;
}
// Driver code
public static void Main()
{
    int n = 3;
    Console.WriteLine(IcositrigonalNum(n));
    n = 10;
    Console.WriteLine(IcositrigonalNum(n));
}
}
// This code is contributed by spp____

java 描述语言


Output: 

66
955

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


推荐阅读
author-avatar
dsjdsjdsjjk_896
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有