| 1234567891011121314151617 |
- program t101_recursion;
- { t101 -- direct self-recursion. The function's result variable shadows its
- own name inside the body; a following '(' must resolve to the function
- symbol, not the result slot. }
- function fact (N : integer) : integer;
- begin
- if N <= 1 then
- fact := 1
- else
- fact := N * fact (N - 1)
- end;
- begin
- writeln (fact (5))
- end.
|