Given a number N, the task is to find Nth Hexahectagon number

By | November 5, 2024

In this article, we will discuss about Hexahectagon number. According to definition of Hexahectagon number:

A Hexahectagon number is class of figurate number. It has 600 – sided polygon called Hexahectagon. The N-th Hexahectagon number count’s the 600 number of dots and all others dots are surrounding with a common sharing corner and make a pattern. The first few Hexahectagonol numbers are 1, 600, 1797, 3592, 5985 … 

Examples:

Input: N = 2
Output: 600
Explanation:
The second Hexahectagonol number is 600.
Input: N = 3
Output: 1797

Approach: The N-th Hexahectagon number is given by the formula:

Nth term of s sided polygon =

Therefore Nth term of 600 sided polygon is =

Below is the simply implementation of the above approach in Python –

# Python3 program to find the N-th 
# Hexahectagon number 
  
# Function to find the N-th 
# Hexahectagon number 
def HexahectagonNum(N): 
  
    return (598 * N * N - 596 * N) // 2
  
# Driver code 
n = 3
print(HexahectagonNum(n)) 

Output:

1797

The time complexity of this program is O(1) because of no loops and no recursion. We have only formula calculation which is constant.

Author: Mithlesh Upadhyay

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.