Here is a Fortran 95 program to compute the factorial of 0 through 5. The factorial can be computed as the product of an array created on the fly, without an explicit loop.
program xfact
integer :: i
print*,fact([(i,i=0,5)])
contains
elemental function fact(n)
integer, intent(in) :: n
integer :: i,fact
fact = product([(i,i=1,n)])
end function fact
end program xfact
program xfact
integer::i
print *, fact ([(i, i = 0, 5)])
contains
elemental function fact (n)
integer, intent (in)::n
integer::i
fact = product ([(i, i = 1, n)])
end function fact
end program xfact
program xfact integer :: i print*,fact([(i,i=0,5)]) contains elemental function fact(n) integer, intent(in) :: n integer :: i,fact fact = product([(i,i=1,n)]) end function fact end program xfact