Skip to content

Instantly share code, notes, and snippets.

@natebenes
Created March 28, 2010 00:42
Show Gist options
  • Save natebenes/346464 to your computer and use it in GitHub Desktop.
Save natebenes/346464 to your computer and use it in GitHub Desktop.
PROGRAM ComputeFactorial
! @author: Nate Benes
USE FactorialModule
IMPLICIT NONE
INTEGER, DIMENSION(2,10) :: arrayOfNumbers
INTEGER :: userInput, factorial
INTEGER :: total = 0,i,m,n
! One of many ways to fill the array.
! reading from a file is also OK
DO
READ(*,*) userInput
IF (userInput < 1) EXIT
! Count how many numbers we have entered so far
total = total + 1
arrayOfNumbers(1,total) = userInput
arrayOfNumbers(2,i) = factorial(userInput)
! Keeps us from counting past 10
IF (total == 10) EXIT
END DO
WRITE(*,60) ((arrayOfNumbers(m,n),m=1,2),n=1,total)
60 FORMAT(2I)
EXIT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment