bsc

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

P037.c (511B)


      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 /* sum = 1 + 1+2/1*2 + 1+2+3/1*2*3 + ... + 1+2+3+...+n/1*2*3*...*n */
      8 
      9 #include <stdio.h>
     10 
     11 int main()
     12 {
     13     double sum = 0, temp1 = 0, temp2 = 1;
     14     int n, i;
     15     printf("Enter value for n : ");
     16     scanf("%d", &n);
     17     for (i = 1; i <= n; i++)
     18     {
     19         temp1 += i;
     20         temp2 *= i;
     21         sum += temp1 / temp2;
     22     }
     23     printf("\nSum = %g", sum);
     24     return 0;
     25 }
© notamitgamer • Site Built: 2026-07-21 13:58:23 UTC • git-mirror commit: 1037f62 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror