Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
program endless_sum;
var
x, i, j: integer;
y, sum: extended;
function power(x, n: integer): longint;
var
a, b: integer;
begin
if (n = 0) then power := 1;
if (n = 1) then power := x
else
begin
a := x;
for b := 2 to n do
a := a * x;
power := a;
end;
end;
begin
i := 1;
write('input x: ');
readln(x);
sum := x;
y := power(-1, i) * power(x, 2 * i);
for j := 1 to 2 * i do
y := y / j;
while (abs(y) > 0.0001) do
begin
sum := sum + y;
i := i + 1;
y := power(-1, i) * x;
for j := 2 to 2 * i do
y := y * x / j;
end;
writeln(sum:5:4);
readln();
end.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question