P037.c ​
Metadata ​
- Author — Amit Dutta (amitdutta4255@gmail.com)
- Last updated — 12 Dec 2025
- License — MIT
Problem Statement ​
Problem Statement
sum = 1 + 1+2/12 + 1+2+3/123 + ... + 1+2+3+...+n/123...*n
Source Code ​
Printing the code
To print this file, open it on GitHub and click Raw before printing, or use the Download Raw button above and print directly from that page.
c
#include <stdio.h>
int main()
{
double sum = 0, temp1 = 0, temp2 = 1;
int n, i;
printf("Enter value for n : ");
scanf("%d", &n);
for (i = 1; i <= n; i++)
{
temp1 += i;
temp2 *= i;
sum += temp1 / temp2;
}
printf("\nSum = %g", sum);
return 0;
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17