Ok, i need help not with making the code, but actually calculating it.
Like the code is written and with given values i have to calculate what some variable will end up with what value.
Like i think i'm doing the functions properly, but i always end up with wrong number at the end, so if you can just type numbers instead of letters in step by step, so i know where i go wrong.
Here are the 2 examples, if someone can go step by step solving this:
1) k=2, p=3, r=4, k=?
Program example1;
var
i, j, k, n, p, r: integer;
begin
read (k,p,r);
n:=0;
j:=0;
while(j<r) do
begin
k:= 2*n + k + abs(j-4);
n:=n+1;
j:=j+2;
end;
i:=0
repeat
k:=2*k+sqr(i-1)+n;
for j:=r downto p do
if j mod 2 <>0 then
k:=n+2*(j+1)+k
else
k:=n+2*j+k;
i:=i+2;
until i>=p;
writeln (k)
end.
2) k=7, m=4, k=?
Program example2;
var
i,j,k,n,m,r: integer;
begin
read (k,m);
n:=6;
i:=3;
while (i<5) do
begin
r:=i-1;
for j:=r to m do
begin
n:=n div 3 + k mod j + r;
k:=k + sqr(i-3) + n + j;
end
else
begin
n:= sqr(k div 3) + n mod 3;
k:=abs(k-10) + n;
end;
end;
i:=i+1;
end;
writeln (k)
end.