- 2071 Chaitra · 6 marks
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)
Related questions
- GOTO types; sum of series program · Computer Programming, chapter 11
- nth Fibonacci term prime check · Computer Programming, chapter 6
- Read records until end; show nth record · Computer Programming, chapter 10 · asked 2×
- Series 1+11+111+… by recursion · Computer Programming, chapter 6
- Sum of series Σ1/n² · Computer Programming, chapter 5
- Sum and average between M and N using pointer · Computer Programming, chapter 9
- Midpoint circle: r=30, centre (10,20) · Computer Graphics, chapter 2 · asked 2×
- Bresenham: line (20,10) to (30,18) · Computer Graphics, chapter 2 · asked 4×
- AVL tree for 10 20 30 50 45 40 8 5 3 · Data Structure and Algorithm, chapter 6
- AVL tree for 10, 20, 30, 35, 50, ... · Data Structure and Algorithm, chapter 6