Created
March 9, 2010 22:53
-
-
Save natebenes/327247 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PROGRAM example2 | |
IMPLICIT NONE | |
INTEGER :: n | |
INTEGER :: nMinusOne | |
INTEGER :: runningTotal | |
INTEGER :: out | |
LOGICAL :: skiploop | |
! start program | |
WRITE(*,*) 'Enter the integer:' | |
READ(*,*) n | |
IF (n == 1) THEN | |
out = 0 | |
ELSE | |
runningTotal = n | |
nMinusOne = n | |
DO | |
IF(nMinusOne < 2) THEN | |
EXIT | |
ELSE | |
nMinusOne = nMinusOne - 1 | |
runningTotal = runningTotal * nMinusOne | |
END IF | |
END DO | |
out = runningTotal | |
END IF | |
WRITE(*,*) out | |
END PROGRAM |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment