Sum of the first N centered nonadecagonal numbers

Updated

Given a number N, the task is to find the sum of the first N Centered nonadecagonal numbers.

The first few Centered nonadecagonal number are 1, 20, 58, 115, 191, 286 …

Examples :

Input : N = 2
Output : 21
Explanation :
1, 20 are the first two centered nonadecagonal numbers.

Input : N = 3
Output : 79

Approach :

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

Implementation :

# Python program to find the sum 
# of the first N centered 
# nonadecagonal numbers

# Function to find N-th
# centered nonadecagonal 
# number 
def center_nonadecagonal_num(n):
 
    # Formula to calculate  
    # nth centered nonadecagonal 
    # number 
    return (19 * n * n - 19 * n + 2) // 2
    
  
# Function to find the 
# sum of the first N
# centered nonadecagonal 
# numbers
def sum_center_nonadecagonal_num(n) : 
    
    # Variable to store
    # the sum
    summ = 0
    
    # Iterate through the range
    # 1 to N
    for i in range(1, n + 1):
        summ += center_nonadecagonal_num(i)
    
    return summ
  
# Driver code 
if __name__ == '__main__' : 
          
    n = 2
    
    print(sum_center_nonadecagonal_num(n)) 

Output :

21

Time Complexity : O(N).

Comment
Mithlesh Upadhyay Published 19 Nov 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