Find the sum of the first N decagonal numbers

Updated

Given a number N, the task is to find the sum of the first N decagonal Numbers.

The first few decagonal numbers are 1, 10, 27, 52, 85, 126, 175,…

Examples :

Input : N = 2
Output : 11
Explanation :
1, 10 are the first two decagonal numbers.

Input : N = 3
Output : 38

Approach :

  1. Initially, we need to create a function which will help us to calculate the Nth decagonal number.
  2. Now, run a loop starting from 1 to N, to find ith decagonal numbers.
  3. Add all the above calculated decagonal numbers.
  4. Finally, display the sum of the first N decagonal numbers.

Implementation :

# Python program to find the 
# sum of the first N  
# decagonal numbers

# Function to find the 
# N-th decagonal 
# number 
def decagonal_num(n):
 
    # Formula to calculate  
    # nth decagonal 
    # number
    return (8 * n * n - 
            6 * n) // 2
    
  
# Function to find the 
# sum of the first N
# decagonal number 
def sum_decagonal_num(n) : 
    
    # Variable to store
    # the sum
    summ = 0
    
    # Iterating in the range 
    # 1 to N
    for i in range(1, n + 1):

        summ += decagonal_num(i)
    
    return summ
  
# Driver code 
if __name__ == '__main__' : 
          
    n = 2
    

    print(sum_decagonal_num(n)) 

Output :

11

Time Complexity : O(N).

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