RosettaCodeData/Task/Mutual-recursion/00DESCRIPTION

18 lines
594 B
Text
Raw Permalink Normal View History

2015-02-20 00:35:01 -05:00
Two functions are said to be mutually recursive if the first calls the second,
and in turn the second calls the first.
2013-04-10 21:29:02 -07:00
Write two mutually recursive functions that compute members of the [[wp:Hofstadter sequence#Hofstadter Female and Male sequences|Hofstadter Female and Male sequences]] defined as:
2016-12-05 22:15:40 +01:00
<big>
2013-04-10 21:29:02 -07:00
:<math>
\begin{align}
F(0)&=1\ ;\ M(0)=0 \\
F(n)&=n-M(F(n-1)), \quad n>0 \\
M(n)&=n-F(M(n-1)), \quad n>0.
\end{align}
</math>
2016-12-05 22:15:40 +01:00
</big>
2013-04-10 21:29:02 -07:00
2015-02-20 00:35:01 -05:00
<br>(If a language does not allow for a solution using mutually recursive functions
then state this rather than give a solution by other means).
2016-12-05 22:15:40 +01:00
<br><br>