! 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 E25M
    implicit none
    public :: Factorial
  contains
    recursive function Factorial( N ) result( Factorial_R )
      integer, intent(in) :: N
      integer :: Factorial_R
  ! start function Factorial
      if (N == 0) then
        Factorial_R = 1
      else
        Factorial_R = N * Factorial( N - 1 )  ! Recursive call to Factorial
      end if
      return
    end function Factorial
  end module E25M
