!-----  Ex6_4: Eratosthenes Sieve   -----
   PROGRAM Ex6_4
      INTEGER :: index(10000), prime(10000), max = 0, n, m = 0
      DO WHILE( max <= 1  .OR.  max > 10000  )
            PRINT*, 'Upper limit(<10000) ?'
            READ*, max
      END DO
      index = 1
      DO n = 2, INT( max**0.5 )
           IF( index(n) == 0 ) CYCLE
           index( n**2 : max : n ) = 0
      END DO
      DO n = 2, max
         IF( index(n) == 1 ) THEN
            m = m+ 1
            prime(m) = n
         END IF
      END DO
      PRINT '(I5, A)', m, "個見つかりました。"
      PRINT '(10I5)', prime(1:m)
   END PROGRAM Ex6_4
