C program to find Decagonal Number?

A decagonal number is a figurate number that represents the number of dots that can be arranged in nested decagonal (10-sided) patterns. These numbers follow the formula 4n² - 3n, where n is the position in the sequence.

For example, the 3rd decagonal number involves arranging dots in 3 nested decagons. Each nested layer contributes a specific number of dots, and we subtract the overlapping dots to get the final count.

Decagonal Number Pattern Outer: 30 dots Middle: 20 dots Inner: 10 dots Total: 30 + 20 + 10 - 8 = 52 Formula: 4n² - 3n = 4(3²) - 3(3) = 36 - 9 = 27

Syntax

decagonal_number = 4 * n * n - 3 * n

Example: Calculate Single Decagonal Number

This program calculates the decagonal number for a given position −

#include <stdio.h>

int decagonalNumber(int n) {
    return 4 * n * n - 3 * n;
}

int main() {
    int n = 5;
    int result = decagonalNumber(n);
    
    printf("The %dth decagonal number is: %d<br>", n, result);
    
    return 0;
}
The 5th decagonal number is: 85

Example: Generate Decagonal Number Series

This program generates the first n decagonal numbers −

#include <stdio.h>

int decagonalNumber(int n) {
    return 4 * n * n - 3 * n;
}

int main() {
    int count = 8;
    
    printf("First %d decagonal numbers:<br>", count);
    
    for(int i = 1; i <= count; i++) {
        printf("%d ", decagonalNumber(i));
    }
    printf("<br>");
    
    return 0;
}
First 8 decagonal numbers:
1 10 27 52 85 126 175 232

Key Points

  • The formula 4n² - 3n directly computes the nth decagonal number
  • The sequence starts with 1, 10, 27, 52, 85, 126, ...
  • Each number represents dots arranged in nested decagonal patterns

Conclusion

Decagonal numbers follow a simple quadratic formula that makes them easy to compute. The pattern represents an interesting geometric arrangement of dots in nested 10-sided figures.

Updated on: 2026-03-15T10:50:19+05:30

177 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements