Heptacontadigon number
Last Updated :
16 Jun, 2021
Given a number N, the task is to find Nth Heptacontadigon number.
A Heptacontadigon Number is a class of figurate numbers. It has a 72-sided polygon called Heptacontadigon. The N-th Heptacontadigon number count’s the 72 number of dots and all other dots are surrounding with a common sharing corner and make a pattern. The first few Heptacontadigonol numbers are 1, 72, 213, 424, …
Examples:
Input: N = 2
Output: 72
Explanation:
The second Heptacontadigonol number is 72.
Input: N = 3
Output: 213
Approach: The N-th Heptacontadigon number is given by the formula:
- N-th term of S sided polygon =
- Therefore, the N-th term of 72 sided polygon is given by:
Below is the implementation of the above approach:
C++
#include <bits/stdc++.h>
using namespace std;
int HeptacontadigonNum( int N)
{
return (70 * N * N - 68 * N)
/ 2;
}
int main()
{
int N = 3;
cout << HeptacontadigonNum(N);
return 0;
}
|
Java
class GFG{
static int HeptacontadigonNum( int N)
{
return ( 70 * N * N - 68 * N) / 2 ;
}
public static void main(String[] args)
{
int N = 3 ;
System.out.println(HeptacontadigonNum(N));
}
}
|
Python3
def HeptacontadigonNum(N):
return ( 70 * N * N - 68 * N) / / 2 ;
N = 3 ;
print (HeptacontadigonNum(N));
|
C#
using System;
class GFG{
static int HeptacontadigonNum( int N)
{
return (70 * N * N - 68 * N) / 2;
}
public static void Main()
{
int N = 3;
Console.Write(HeptacontadigonNum(N));
}
}
|
Javascript
<script>
function HeptacontadigonNum(N)
{
return parseInt((70 * N * N - 68 * N) / 2, 10);
}
let N = 3;
document.write(HeptacontadigonNum(N));
</script>
|
Time Complexity: O(1)
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...