Skip to content

Instantly share code, notes, and snippets.

@prefork
Created March 9, 2010 22:53
Show Gist options
  • Save prefork/327247 to your computer and use it in GitHub Desktop.
Save prefork/327247 to your computer and use it in GitHub Desktop.
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