Jump to content

Mutual recursion: Difference between revisions

m
→‎{{header|REXX}}: added some comments. -- ~~~~
No edit summary
m (→‎{{header|REXX}}: added some comments. -- ~~~~)
Line 1,435:
 
=={{header|REXX}}==
<lang rexx>/*REXX program to show mutual recursion. */
arg limit .; if limit='' then limit=40
/*REXX program to show mutual recursion. */
do j=0 to limit
 
say 'F('right(j,2)")="right(F(j),9) ' M('right(j,2)")="right(M(j),9)
arg limit .
end
if limit='' then limit=40
 
do j=0 to limit
say 'F('right(j,2)")="right(F(j),9) ' M('right(j,2)")="right(M(j),9)
end
 
exit
/*─────────────────────────────────────F & M subroutines─────────────*/
 
 
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))</lang>
Output'''output'' (using the default of 40):
</lang>
Output (using the default of 40):
<pre style="height:30ex;overflow:scroll">
F( 0)= 1 M( 0)= 0
Cookies help us deliver our services. By using our services, you agree to our use of cookies.