Skip to content

Instantly share code, notes, and snippets.

@own2pwn
Created October 26, 2016 10:36
Show Gist options
  • Save own2pwn/f10ac1a318b6fd204d3e56b57a8a8dc7 to your computer and use it in GitHub Desktop.
Save own2pwn/f10ac1a318b6fd204d3e56b57a8a8dc7 to your computer and use it in GitHub Desktop.
program p3;
var
xEnd, x, eps, count, t, y, index: Real;
ind2: Integer;
function power(x: real; n: integer): real;
var
i: integer;
step: real;
begin
step := 1;
for i := 1 to n do
step := step * x;
power := step;
end;
begin
count := 0;
eps := 0.0001;
t := 1;
index := 1;
y := 0;
x := -1;
while x <= 1 do
begin
y := 0;
index := 3;
ind2 := 1;
repeat
t := power(x, index) / index;
y := y + (x + (t * power(-1, ind2 mod 2)));
index := index + 2;
ind2 := ind2 + 1;
until t < eps;
writeln('x = ', x:5, ' | y = ', y:5);
x := x + 0.25
end;
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment