HomeAboutCodePastes

Paste on 2021-04-03T20:04:46

(import (chicken fixnum))
(define ps (make-vector 2000001 #t))
(define ~ vector-ref)
(define ! vector-set!)
(! ps 0 #f)
(! ps 1 #f)
(let loop ((n 2))
  (if (fx> n 2000000)
      #f
      (begin
        (do ((m (fx+ n n) (fx+ n m)))
            ((fx> m 2000000))
          (! ps m #f))
        (loop (fx+ n 1)))))

(define (prime? n)
  (~ ps n))

(print (prime? 331))

plain