Skip to content

p037.c

Problem Statement

sum = 1 + 1+2/12 + 1+2+3/123 + ... + 1+2+3+...+n/123...*n

Metadata

Property Detail
Author Amit Dutta (amitdutta4255@gmail.com)
License MIT

Actions

Raw View on GitHub

💡 You can print or save this file by opening Raw and using your browser.

Source Code

#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;
}