- #1
Sue Parks
- 38
- 0
I have a list of factorials from 1 -100. I can print them to the console without a format problem. I used the kind() function for formatting the output. I have tried to put these numbers into an array, but I get an error when I try to print the array
PRINT *, FACTORIALS (F)
1
Warning: Legacy Extension: REAL array index at (1)
PRINT *, FACTORIALS (F)
1
Warning: Legacy Extension: REAL array index at (1)
Fortran:
PROGRAM CALCULATE_FACTORIAL
IMPLICIT NONE
INTEGER, PARAMETER:: DIGITS = SELECTED_REAL_KIND(2,40)
REAL (KIND=DIGITS) :: F
REAL, allocatable, DIMENSION(:) :: FACTORIALS ! array that will hold the primes
INTEGER:: A, N
REAL :: ELEMENTS, I
ALLOCATE (FACTORIALS(n))
FACTORIALS (1)= 1.0
F = 1.0
N = 1
I =1
ELEMENTS =0
A=0
DO
print *, F
N =N +1
F =F * N
!F = ELEMENTS
IF ( N == 101 ) THEN
EXIT
END IF
PRINT *, FACTORIALS (F)
END DODEALLOCATE (FACTORIALS)END PROGRAM CALCULATE_FACTORIAL