Heptacontadigon number
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++
// C++ program for the above approach #include <bits/stdc++.h> 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 |
Javascript
<script> // JavaScript program for the above approach // Function to find the N-th // Heptacontadigon Number function HeptacontadigonNum(N) { return parseInt((70 * N * N - 68 * N) / 2, 10); } // Given number N let N = 3; // Function Call document.write(HeptacontadigonNum(N)); </script> |
Output:
213
Time Complexity: O(1)