Given a number N, the task is to find Nth Hecatochiliagon number.
A Hecatochiliagon number is class of figurate number. It has 100000 – sided polygon called Hecatochiliagon. The N-th Hecatochiliagon number count’s the 100000 number of dots and all others dots are surrounding with a common sharing corner and make a pattern. The first few Hecatochiliagon numbers are 1, 100000, 299997, 599992, 999985 …
Examples :
Input : N = 2 Output : 100000 Explanation : The second Hecatochiliagon number is 100000. Input : N = 3 Output : 299997
Approach :
The N-th Hecatochiliagon number is given by the formula:
- Nth term of s sided polygon =
\[\frac{((s-2)n^2 – (s-4)n)}{2}\]
- Therefore Nth term of 100000 sided polygon is
\[Tn =\frac{((100000-2)n^2 – (100000-4)n)}{2} =\frac{(99998n^2 – 99996n)}{2}\]
Implementation :
# Python3 program to find the N-th
# Hecatochiliagon number
# Function to find the N-th
# Hecatochiliagon number
def HecatochiliagonNum(N):
return (99998 * N * N - 99996 * N) // 2
# Driver code
n = 3
print(HecatochiliagonNum(n))
Output :
299997