PROGRAM Prime_numbers IMPLICIT NONE INTEGER, ALLOCATABLE, DIMENSION(:) :: Prime INTEGER :: N_elts, i ,j PRINT*, "Type in the size of the array" READ*, N_elts ALLOCATE (Prime(N_elts), STAT=i) IF (i.NE.0) THEN PRINT*, "Allocation request failed" STOP ENDIF Prime = (/ (i, i = 1,N_elts) /) i = 2 outa : DO DO j=i+1,N_elts IF (MOD(Prime(j),i).EQ.0) Prime(j) = 0 ENDDO DO i = i + 1 IF (i .EQ. N_elts) EXIT outa IF (Prime(i) .NE. 0) EXIT END DO END DO outa DO i = 1, N_elts IF (Prime(i) .NE. 0) WRITE(*,*) Prime(i) END DO DEALLOCATE(Prime) STOP END PROGRAM Prime_Numbers