! ! =====> Program - P46.F90 ! ! ! FACTORIAL N ! INTEGER FACT ! ! PRINT *, 'This is Program >> P46 - Factorial program' ! ! ! Tell program where data for READ * is coming from OPEN(UNIT=5, FILE='P46.DAT') ! UNIT=5 is the default input ! PRINT 1000 1000 FORMAT(' Factorial Program'/) L1: DO READ *,N IF(N < 0) STOP ! or EXIT in this case ! FACT=1 L2: DO I=2,N FACT=FACT*I END DO L2 ! PRINT 10,N,FACT 10 FORMAT(' Factorial',I3,' =',I8) ! END DO L1 END DATA: 5 10 0 -9 OUTPUT: Program entered This is Program >> P46 - Factorial program Factorial Program Factorial 5 = 120 Factorial 10 = 3628800 Factorial 0 = 1 Fortran-90 STOP
Page builder: Charles Boivin
Last modified: 11/07/95