P031.c ​
Metadata ​
- Author — Amit Dutta (amitdutta4255@gmail.com)
- Last updated — 12 Dec 2025
- License — MIT
Problem Statement ​
Problem Statement
Find the sum of the series
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>
#include <math.h>
int main()
{
double a, res, n;
int i;
// s = (a ^ 2) + (a ^ 2 / 2) + (a ^ 2 / 3) + ... + (a ^ 2 / 10)
{
res = 0, i = 1;
printf("--- s = (a ^ 2) + (a ^ 2 / 2) + (a ^ 2 / 3) + ... + (a ^ 2 / 10) ---");
printf("\nEnter the number : ");
scanf("%lf", &a);
while (i <= 10)
{
res = res + ((a * a) / i);
i++;
}
printf("S = %g", res);
}
// s = 1 + (2 ^ 2 / a) + (3 ^ 3 / a ^ 2) + ... + n
{
res = 0, i = 0;
printf("\n--- // s = 1 + (2 ^ 2 / a) + (3 ^ 3 / a ^ 2) + ... + n ---");
printf("\nEnter the value for a and n : ");
scanf(" %lf %lf", &a, &n);
while (i <= n - 1)
{
res = res + (pow(i + 1, i + 1) / pow(a, i));
i++;
}
printf("S = %g", res);
}
return 0;
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38