Mutual recursion: Difference between revisions

Content added Content deleted
m (→‎{{header|REXX}}: added more whitespace to output notes.)
m (→‎vanilla: removed last blank line in program.)
Line 1,739: Line 1,739:
F: procedure; parse arg n; if n==0 then return 1; return n-M(F(n-1))
F: procedure; parse arg n; if n==0 then return 1; return n-M(F(n-1))
M: procedure; parse arg n; if n==0 then return 0; return n-F(M(n-1))
M: procedure; parse arg n; if n==0 then return 0; return n-F(M(n-1))
Jw: return right(arg(1),length(lim)) /*right justifies # for nice look*/
Jw: return right(arg(1),length(lim)) /*right justifies # for nice look*/</lang>
</lang>
'''output''' using the default input of: &nbsp; <tt> 40 </tt>
'''output''' using the default input of: &nbsp; <tt> 40 </tt>
<pre style="height:30ex">
<pre style="height:30ex">
Line 1,785: Line 1,784:
F(40) = 25 M(40) = 25
F(40) = 25 M(40) = 25
</pre>
</pre>

===with memoization===
===with memoization===
This version uses memoization as well as a horizontal output format.
This version uses memoization as well as a horizontal output format.