Find the Nth Triacontakaihenagonal Number

By | December 1, 2024

Given a number N, the task is to find Nth triacontakaihenagonal number.

A triacontakaihenagonal number is class of figurate number. It has 31 – sided polygon called triacontakaihenagon. The N-th triacontakaihenagonal number count’s the 31 number of dots and all others dots are surrounding with a common sharing corner and make a pattern. The first few triacontakaihenagonol numbers are 1, 31, 90, 178 …

Examples:

Input: N = 2
Output: 31
Explanation:
The second triacontakaihenagonol number is 31.

Input: N = 3
Output: 90

Approach: The N-th triacontakaihenagonal number is given by the formula:
Nth term of s sided polygon = (((s-2)n^2 – (s-4)n)) / 2

Therefore Nth term of 31 sided polygon is –

Below is the implementation of the above approach:

// C program for the above approach
#include <stdio.h>
#include <stdlib.h>

// Finding the nth triacontakaihenagonal Number
int triacontakaihenagonalNum(int n)
{
    return (29 * n * n - 27 * n) / 2; 
}

// Driver program to test the above function
int main()
{
    int n = 3;
    printf("3rd triacontakaihenagonal Number is = %d", 
           triacontakaihenagonalNum(n));

    return 0;
}

Output:

3rd triacontakaihenagonal Number is =  90
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.