Answer:
The algorithm is as follows:
Input x
sum_a = 0
sum_b = 0
sum_c = 0
for i = 0 to 20
sum_a = sum_a + x^i
sum_b = sum_b + (-x)^i
sum_c = sum_c + x^i/(i+1)
print sum_a, sum_b, sum_c
Explanation:
Required
An algorithm to solve (a), (b) and (c)
For Series (a):
This series is a geometric progression and the common ratio is x
i.e.
[tex]r = x/1 = x^2/x = ...... = x^{n+1}/x^n =x[/tex]
So, the sum of the series is:
Sum = Previous Sums + x^i --- where i is between 0 and 20 (inclusive)
For Series (b):
This series is a geometric progression and the common ratio is -x
i.e.
[tex]r = -x/1 = -x^2/x = ...... = -(x^{n+1}/x^n) = -x[/tex]
So, the sum of the series is:
Sum = Previous Sums + (-x^i) --- where i is between 0 and 20 (inclusive)
For Series (c):
This series is a neither arithmetic nor geometric progression.
It obeys the following rule:
[tex]\frac{x^i}{1+i}[/tex] --- where i is between 0 and 20 (inclusive)
So, the sum of the series is:
Sum = Previous Sums + [tex]\frac{x^i}{1+i}[/tex]