Integer Function Factorial(n)
Implicit None
Integer, Intent(IN) :: n !formal input parameter
Integer :: I, Ans !local variables
Ans = 1
DO I = 1, n
Ans = Ans * I
END DO
Factorial = Ans
END FUNCTION Factorial
What is wrong with the following version?
Integer Function Factorial(n) Implicit None Integer, Intent(IN) :: n Integer :: i Factorial = 1 DO i = 1, n Factorial = Factorial * i ! the ``bug'' is here END DO END FUNCTION Factorial