Solution for exercise 04

Review

  1. Correct dimensioning can be:
    DIMENSION POSITION (3), VELO(2)
    REAL, DIMENSION(3) :: ACCEL
    Note that the double colon is required if DIMENSION is used as an attribute. Therefore the first line was wrong.
  2. The arguments of function and subroutines are always passed per address.

Task 1 - Recursive function

We can split the the whole code into the PROGRAM and a recursive function:

program calc_fac

recursive function factorial