P052.c (716B)
1 /* 2 * Author: Amit Dutta (amitdutta4255@gmail.com) | Date: 12 Dec 2025 3 * Repo: https://github.com/notamitgamer/bsc 4 * License: MIT 5 */ 6 7 /* Print the sum of this series for upto n element. 8 Series: 1 + (1 + 2) + (1 + 2 + 3) + (1 + 2 + 3 + 4) + ... + (1 + 2 + 3 + ... + n) */ 9 10 // This code has not been compiled. 11 // If you find any issues, please create a new issue on GitHub regarding them. 12 // Go to this link to create a new issue: https://github.com/notamitgamer/bsc/issues 13 14 #include <stdio.h> 15 16 int main() 17 { 18 int n, sum = 0, temp = 0, i; 19 printf("Enter the n : "); 20 scanf("%d", &n); 21 for (i = 1; i <= n; i++) 22 { 23 temp += i; 24 sum += temp; 25 } 26 printf("%d", sum); 27 return 0; 28 }