! 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.

! Example 4.13. Calculate factorial of Limit.
  program E13
    implicit none
    integer :: Factorial, Limit, Loop
! start program E13
    do
      Factorial = 1
      write (unit = *, fmt = *) " Please enter the number whose factorial is wanted. "
      read (unit = *, fmt = *) Limit
      if (Limit < 0) then
        exit
      end if
      do Loop = 1, Limit
        Factorial = Factorial * Loop
      end do
      write (unit = *, fmt = *) " Factorial of: ", Limit, " is: ", Factorial
    end do
    stop
  end program E13
