Enneacontahexagon numbers
Given a number N, the task is to find Nth Enneacontahexagon number.
An Enneacontahexagon number is a class of figurate numbers. It has a 96-sided polygon called Enneacontahexagon. The N-th Enneacontahexagon number count’s the 96 number of dots and all other dots are surrounding with a common sharing corner and make a pattern. The first few Enneacontahexagonol numbers are 1, 96, 285, 568, 945, 1416, …
Examples:
Input: N = 2
Output: 96
Explanation:
The second Enneacontahexagonol number is 96.
Input: N = 3
Output: 285
Approach: The N-th Enneacontahexagon number is given by the formula:
- Nth term of s sided polygon =
- Therefore Nth term of 96 sided polygon is
Below is the implementation of the above approach:
C++
#include <bits/stdc++.h>
using namespace std;
int EnneacontahexagonNum( int n)
{
return (94 * n * n - 92 * n) / 2;
}
int main()
{
int n = 3;
cout << EnneacontahexagonNum(n);
return 0;
}
|
Java
class GFG{
static int enneacontahexagonNum( int n)
{
return ( 94 * n * n - 92 * n) / 2 ;
}
public static void main(String[] args)
{
int n = 3 ;
System.out.print(enneacontahexagonNum(n));
}
}
|
Python3
def EnneacontahexagonNum(n):
return ( 94 * n * n - 92 * n) / / 2 ;
n = 3 ;
print (EnneacontahexagonNum(n));
|
C#
using System;
class GFG{
static int enneacontahexagonNum( int n)
{
return (94 * n * n - 92 * n) / 2;
}
public static void Main()
{
int n = 3;
Console.Write(enneacontahexagonNum(n));
}
}
|
Javascript
<script>
function EnneacontahexagonNum( n) {
return (94 * n * n - 92 * n) / 2;
}
let n = 3;
document.write(EnneacontahexagonNum(n));
</script>
|
Reference: https://en.wikipedia.org/wiki/Enneacontahexagon
Last Updated :
23 Mar, 2021
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...