27 lines
587 B
Plaintext
27 lines
587 B
Plaintext
/* We need to predeclare M if we want F to be able to see it.
|
|
* This is done using 'extern', same as if it had been in a
|
|
* different compilation unit. */
|
|
extern M(byte n) byte;
|
|
|
|
/* Mutually recursive functions */
|
|
proc F(byte n) byte:
|
|
if n=0 then 1 else n - M(F(n-1)) fi
|
|
corp
|
|
|
|
proc M(byte n) byte:
|
|
if n=0 then 0 else n - F(M(n-1)) fi
|
|
corp
|
|
|
|
/* Show the first 16 values of each */
|
|
proc nonrec main() void:
|
|
byte i;
|
|
|
|
write("F:");
|
|
for i from 0 upto 15 do write(F(i):2) od;
|
|
writeln();
|
|
|
|
write("M:");
|
|
for i from 0 upto 15 do write(M(i):2) od;
|
|
writeln()
|
|
corp
|