PROGRAM Faculteit

2 Implicit None

3 Integer :: N,Result

4 Result=0

5 N=4

6 Call Factorial(N,Result)

7

8 100 Print*,' N:',N,' Facorial:',Result

9

10 END PROGRAM

11

12

13

14 !

15 !=================================================================

16 RECURSIVE SUBROUTINE Factorial(N, Result)

17 IMPLICIT NONE

18 INTEGER, INTENT(IN) :: N

19 INTEGER, INTENT(INOUT) :: Result

20 IF (N > 0) THEN

21 CALL Factorial(N-1,Result)

22 Result = Result * N

23 ELSE

24 Result = 1

25 END IF

26 END SUBROUTINE Factorial

27 !=================================================================