Mutual recursion: Difference between revisions
Content added Content deleted
Capra Hircus (talk | contribs) (adding maxima) |
(Added XPL0 example) |
||
Line 2,156: | Line 2,156: | ||
end</lang> |
end</lang> |
||
=={{header|XPL0}}== |
|||
<lang XPL0>code ChOut=8, CrLf=9, IntOut=11; |
|||
ffunc M; \forward-referenced function declaration |
|||
func F(N); |
|||
int N; |
|||
return if N=0 then 1 else N - M(F(N-1)); |
|||
func M(N); |
|||
int N; |
|||
return if N=0 then 0 else N - F(M(N-1)); |
|||
int I; |
|||
[for I:= 0 to 19 do [IntOut(0, F(I)); ChOut(0, ^ )]; |
|||
CrLf(0); |
|||
for I:= 0 to 19 do [IntOut(0, M(I)); ChOut(0, ^ )]; |
|||
CrLf(0); |
|||
]</lang> |
|||
Output: |
|||
<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> |