bsc

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

P031.c (1073B)


      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 /* Find the sum of the series */
      8 
      9 #include <stdio.h>
     10 #include <math.h>
     11 
     12 int main()
     13 {
     14     double a, res, n;
     15     int i;
     16 
     17     // s = (a ^ 2) + (a ^ 2 / 2) + (a ^ 2 / 3) + ... + (a ^ 2 / 10)
     18     {
     19         res = 0, i = 1;
     20         printf("--- s = (a ^ 2) + (a ^ 2 / 2) + (a ^ 2 / 3) + ... + (a ^ 2 / 10) ---");
     21         printf("\nEnter the number : ");
     22         scanf("%lf", &a);
     23         while (i <= 10)
     24         {
     25             res = res + ((a * a) / i);
     26             i++;
     27         }
     28         printf("S = %g", res);
     29     }
     30 
     31     // s = 1 + (2 ^ 2 / a) + (3 ^ 3 / a ^ 2) + ... + n
     32     {
     33         res = 0, i = 0;
     34         printf("\n--- // s = 1 + (2 ^ 2 / a) + (3 ^ 3 / a ^ 2) + ... + n ---");
     35         printf("\nEnter the value for a and n : ");
     36         scanf(" %lf %lf", &a, &n);
     37         while (i <= n - 1)
     38         {
     39             res = res + (pow(i + 1, i + 1) / pow(a, i));
     40             i++;
     41         }
     42         printf("S = %g", res);
     43     }
     44 
     45     return 0;
     46 }
© 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