Skip to content

Instantly share code, notes, and snippets.

@natebenes
Created April 21, 2010 19:15
Show Gist options
  • Save natebenes/374272 to your computer and use it in GitHub Desktop.
Save natebenes/374272 to your computer and use it in GitHub Desktop.
RECURSIVE FUNCTION factorial(n) RESULT(FactNum)
IMPLICIT NONE
INTEGER :: FactNum
INTEGER, INTENT(IN) :: n
! What if fact < 0 ?
IF (n==0) THEN
Fact = 1
ELSE
Fact = n * Factorial(n-1)
END IF
END FUNCTION
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment