Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
34
Task/Mutual-recursion/Pascal/mutual-recursion.pas
Normal file
34
Task/Mutual-recursion/Pascal/mutual-recursion.pas
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
Program MutualRecursion;
|
||||
|
||||
{M definition comes after F which uses it}
|
||||
function M(n : Integer) : Integer; forward;
|
||||
|
||||
function F(n : Integer) : Integer;
|
||||
begin
|
||||
if n = 0 then
|
||||
F := 1
|
||||
else
|
||||
F := n - M(F(n-1));
|
||||
end;
|
||||
|
||||
function M(n : Integer) : Integer;
|
||||
begin
|
||||
if n = 0 then
|
||||
M := 0
|
||||
else
|
||||
M := n - F(M(n-1));
|
||||
end;
|
||||
|
||||
var
|
||||
i : Integer;
|
||||
|
||||
begin
|
||||
for i := 0 to 19 do begin
|
||||
write(F(i) : 4)
|
||||
end;
|
||||
writeln;
|
||||
for i := 0 to 19 do begin
|
||||
write(M(i) : 4)
|
||||
end;
|
||||
writeln;
|
||||
end.
|
||||
Loading…
Add table
Add a link
Reference in a new issue