Mutual recursion: Difference between revisions
Content deleted Content added
No edit summary |
Added PascalABC.NET |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 1,323:
=={{header|EasyLang}}==
<syntaxhighlight lang=text>
funcdecl M n .
func F n .
Line 1,448:
</pre>
=={{header|
<syntaxhighlight lang="emal">
fun F
fun M
write("F: ")
range(0, 21).list(<int n|write(F(n) + ", "))
Line 3,161 ⟶ 3,155:
writeln;
end.</syntaxhighlight>
=={{header|PascalABC.NET}}==
<syntaxhighlight lang="delphi">
##
function M(n: integer): integer; forward;
function F(n: integer): integer := n < 1 ? 1 : n - M(F(n - 1));
function M(n: integer): integer := n < 1 ? 0 : n - F(M(n - 1));
(0..19).select(x -> F(x)).println;
(0..19).select(x -> M(x)).println;
</syntaxhighlight>
{{out}}
<pre>
1 1 2 2 3 3 4 5 5 6 6 7 8 8 9 9 10 11 11 12
0 0 1 2 2 3 4 4 5 6 6 7 7 8 9 9 10 11 11 12
</pre>
=={{header|Perl}}==
|