Find the Nth hecatochiliagon number in Python

Updated

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:

  1. 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
Comment
Next tutorial
Mithlesh Upadhyay Published 5 Dec 2026 · 1 min read

Mithlesh Upadhyay is a Computer Science and AI expert from Madhya Pradesh with strong academic background (BE in CSE and M.Tech in AI) and over six years of experience in technical content development. He has contributed tech articles, led teams, and worked in Full Stack Development and Data Science. He founded the w3colleges.org portal for learning resources.

Related tutorials