bsc

Comprehensive codebase and cou...
Log | Files | Refs | Activity | README | LICENSE

root / semester_1 / tuition-c / P037.c

P037.c (375B)


      1 /* sum = 1 + 1+2/1*2 + 1+2+3/1*2*3 + ... + 1+2+3+...+n/1*2*3*...*n */
      2 
      3 #include <stdio.h>
      4 
      5 int main()
      6 {
      7     double sum = 0, temp1 = 0, temp2 = 1;
      8     int n, i;
      9     printf("Enter value for n : ");
     10     scanf("%d", &n);
     11     for (i = 1; i <= n; i++)
     12     {
     13         temp1 += i;
     14         temp2 *= i;
     15         sum += temp1 / temp2;
     16     }
     17     printf("\nSum = %g", sum);
     18     return 0;
     19 }
© notamitgamer • Site Built: 2026-09-05 01:53:16 UTC • git-mirror commit: c170d72 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror