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