Primes by Trial Division - Apple FORTRAN
4 August 2018
Apple FORTRAN for the Apple ][ is supposedly based on FORTRAN-77 but I found it to be unhappy unless the source more closely resembles FORTRAN-66. * is allowed as an I/O unit, but the output format for the console must be explicitly specified. Also, STOP requires a string argument, which is printed on the console.
INTEGER FOUND, COUNT, I, PRIMES(100) FOUND = 0 COUNT = 2 10 FOUND = FOUND + 1 WRITE (*,'(I6)') COUNT PRIMES(FOUND) = COUNT COUNT = COUNT + 1 I = 1 IF (FOUND .LE. 100) THEN 20 IF (MOD(COUNT,PRIMES(I)) .EQ. 0) THEN COUNT = COUNT + 1 I = 1 ELSEIF (I .EQ. FOUND) THEN GOTO 10 ENDIF I = I + 1 GOTO 20 ELSE GOTO 30 ENDIF 30 STOP 'Done.' END