Recursion in Modula 2
16-Jul-87 20:50:37
Sb: #76530-Recursion in Modula 2
Fm: Richard Bielak 75716,352
To: John Draper 76703,4322
Larry, here is a cute and useful example of recursion:
..
. PROCEDURE WriteOctal (n : INTEGER);
. BEGIN
. IF n <= 7 THEN
. WriteInt (n,1)
. ELSE
. WriteOctal (n DIV 8);
. WriteInt (n MOD 8, 1)
. END
. END WriteOctal;
. This should be as easy as Factorial, but not as obviously converted to
iteration.
…..Richie "To iterate is human, to recurse divine!"