Next: Procedures and Array Arguments
Up: Recursive Procedures
Previous: Recursive Function Example
Subroutines can also be recursive,
RECURSIVE SUBROUTINE Factorial(N, Result)
INTEGER, INTENT(IN) :: N
INTEGER, INTENT(INOUT) :: Result
IF (N > 0) THEN
CALL Factorial(N-1,Result)
Result = Result * N
ELSE
Result = 1
END IF
END SUBROUTINE Factorial
Now try this question
Return to corresponding overview page
Next: Procedures and Array Arguments
Up: Recursive Procedures
Previous: Recursive Function Example
©University of Liverpool, 1997
Wed May 28 20:20:27 BST 1997Not for commercial use.