Skip to main content

Series 1×10+3×20+6×30+…

Short answer

Each term is (i(i+1)/2) * (10i). Sum over i=1 to N using a loop. For N=3, the sum is 250.

Write a program to calculate the series: 1×10+3×20+6×30+…….+ [N(N+1)/2]×10N, where N is an integer term read from the keyboard.

The i-th term is [i(i+1)/2] × (10 × i): the first factor is the triangular number (1, 3, 6, ...) and the second is 10, 20, 30, ... The program adds these terms for i = 1 to N.

#include <stdio.h>
int main(void)
{
    int n, i;
    long sum = 0;
    printf("Enter N: ");
    scanf("%d", &n);
    for (i = 1; i <= n; i++)
        sum += (long)(i * (i + 1) / 2) * (10 * i);   /* term i */
    printf("Sum of the series = %ld\n", sum);
    return 0;
}

Output for N = 3:

Enter N: Sum of the series = 250

Check: 1×10 + 3×20 + 6×30 = 10 + 60 + 180 = 250.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Computer Programming chapter 5 questions →