;;; -*- mode: lisp -*- ;;; $Id: sieve.poplisp,v 1.0 2002/05/03 12:12:00 dada Exp $ (declaim (optimize (speed 3) (safety 0) (debug 0) (space 0) (compilation-speed 0))) (let ((n (parse-integer (or (car pop11::poparglist) "1"))) (flags (make-array 8193 :element-type 'fixnum :initial-element 1))) (loop repeat n of-type fixnum for count of-type fixnum = 0 then 0 do (loop for i fixnum from 2 upto 8192 do (unless (zerop (aref flags i)) (loop for k fixnum from (* 2 i) upto 8192 by i do (setf (aref flags k) 0)) (incf count))) finally (format t "Count: ~D~%" count)))