! Program Example from "Essential Fortran 90 & 95" by Loren P. Meissner
! Copyright 1996. Copying for sale requires permission from the author.
! Otherwise, distribution is permitted if these three lines are included.

  module I11M
    implicit none
    public :: Factorial
  contains
    recursive function Factorial( K ) result( Factorial_R )
      integer, intent (in) :: K
      integer :: Factorial_R
  ! start function Factorial
      if (K <= 1) then
        Factorial_R = 1
      else
        Factorial_R = K * Factorial( K - 1 )  ! Recursive call
      end if
      return
    end function Factorial
  end module I11M
