Sieve of Eratosthenes in DrRacket

1 2 3 4 |
(define (sieve-r list N)(let ([first-prime (first list)]) (cond ((< N (* first-prime first-prime)) list) (else (cons first-prime (sieve-r (filter (lambda (val) (not (equal? (remainder val first-prime) 0))) list) N)))))) (define (sieve n)(let ([initlist (in-range 2 (+ n 1))])(sieve-r (stream->list initlist) n))) |