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.
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.