Two functions are said to be mutually recursive if the first calls the second,
and in turn the second calls the first.

Write two mutually recursive functions that compute members of the Hofstadter Female and Male sequences defined as:










F
(
0
)



=
1
 
;
 
M
(
0
)
=
0




F
(
n
)



=
n
−
M
(
F
(
n
−
1
)
)
,

n
>
0




M
(
n
)



=
n
−
F
(
M
(
n
−
1
)
)
,

n
>
0.






{\displaystyle {\begin{aligned}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{aligned}}}





(If a language does not allow for a solution using mutually recursive functions
then state this rather than give a solution by other means).




            NORMAL MODE IS INTEGER
 
          R SET UP STACK SPACE
 
            DIMENSION STACK(100)
            SET LIST TO STACK
 
          R DEFINE RECURSIVE FUNCTIONS          
          R INPUT ARGUMENT ASSUMED TO BE IN N
 
            INTERNAL FUNCTION(DUMMY)
            ENTRY TO FREC.
            WHENEVER N.LE.0, FUNCTION RETURN 1
            SAVE RETURN
            SAVE DATA N
            N = N-1
            N = FREC.(0)
            X = MREC.(0)
            RESTORE DATA N
            RESTORE RETURN
            FUNCTION RETURN N-X
            END OF FUNCTION
 
            INTERNAL FUNCTION(DUMMY)
            ENTRY TO MREC.
            WHENEVER N.LE.0, FUNCTION RETURN 0
            SAVE RETURN
            SAVE DATA N
            N = N-1
            N = MREC.(0)
            X = FREC.(0)
            RESTORE DATA N
            RESTORE RETURN
            FUNCTION RETURN N-X
            END OF FUNCTION
 
          R DEFINE FRONT-END FUNCTIONS THAT CAN BE CALLED WITH ARGMT
 
            INTERNAL FUNCTION(NN)
            ENTRY TO F.
            N = NN
            FUNCTION RETURN FREC.(0)
            END OF FUNCTION
 
            INTERNAL FUNCTION(NN)
            ENTRY TO M.
            N = NN
            FUNCTION RETURN MREC.(0)
            END OF FUNCTION
 
          R PRINT F(0..19) AND M(0..19)
 
            THROUGH SHOW, FOR I=0, 1, I.GE.20
SHOW        PRINT FORMAT FMT,I,F.(I),I,M.(I)
            VECTOR VALUES FMT = 
          0      $2HF(,I2,4H) = ,I2,S8,2HM(,I2,4H) = ,I2*$
            END OF PROGRAM