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