📜  庚烷对角线数

📅  最后修改于: 2021-05-06 23:20:28             🧑  作者: Mango

给定一个数N ,任务是找到N庚庚二酮数。

例子:

方法:N个庚庚二酮数由下式给出:

下面是上述方法的实现:

C/C++
// C++ program for the above approach
#include 
using namespace std;
  
// Function to find the N-th
// Heptacontadigon Number
int HeptacontadigonNum(int N)
{
    return (70 * N * N - 68 * N)
           / 2;
}
  
// Driver Code
int main()
{
    // Given number N
    int N = 3;
  
    // Function Call
    cout << HeptacontadigonNum(N);
  
    return 0;
}


Java
// Java program for the above approach
class GFG{ 
  
// Function to find the N-th
// Heptacontadigon Number
static int HeptacontadigonNum(int N)
{
    return (70 * N * N - 68 * N) / 2;
}
  
// Driver code 
public static void main(String[] args) 
{ 
    int N = 3;
      
    System.out.println(HeptacontadigonNum(N));
} 
} 
  
// This code is contributed by Pratima Pandey


Python3
# Python3 program for the above approach
  
# Function to find the N-th
# Heptacontadigon Number
def HeptacontadigonNum(N):
  
    return (70 * N * N - 68 * N) // 2;
  
# Driver Code
  
# Given number N
N = 3;
  
# Function Call
print(HeptacontadigonNum(N));
  
# This code is contributed by Code_Mech


C#
// C# program for the above approach
using System;
class GFG{ 
  
// Function to find the N-th
// Heptacontadigon Number
static int HeptacontadigonNum(int N)
{
    return (70 * N * N - 68 * N) / 2;
}
  
// Driver code 
public static void Main() 
{ 
    int N = 3;
      
    Console.Write(HeptacontadigonNum(N));
} 
} 
  
// This code is contributed by Code_Mech


输出:
213

时间复杂度: O(1)