Mutual recursion: Difference between revisions
Content added Content deleted
Line 641: | Line 641: | ||
Female (n: INTEGER): INTEGER |
Female (n: INTEGER): INTEGER |
||
-- Female sequence of the Hofstadter Female and Male sequences. |
-- Female sequence of the Hofstadter Female and Male sequences. |
||
require |
|||
n_not_negative: n >= 0 |
|||
n_is_positive: n > 0 |
|||
do |
do |
||
Result := 1 |
|||
if n /= 0 then |
|||
else |
|||
Result := n - Male (Female (n - 1)) |
Result := n - Male (Female (n - 1)) |
||
end |
end |
||
Line 653: | Line 652: | ||
Male (n: INTEGER): INTEGER |
Male (n: INTEGER): INTEGER |
||
-- Male sequence of the Hofstadter Female and Male sequences. |
-- Male sequence of the Hofstadter Female and Male sequences. |
||
require |
|||
n_not_negative: n >= 0 |
|||
n_is_positive: n > 0 |
|||
do |
do |
||
Result := 0 |
|||
if n /= 0 then |
|||
else |
|||
Result := n - Female (Male (n - 1)) |
Result := n - Female (Male (n - 1)) |
||
end |
end |