CS代考程序代写 (define (sieve n)

(define (sieve n)
(define (iter i primes)
(cond ((= (length primes) n) primes)
((divisBy primes i) (iter (+ i 1) primes))
(else (iter (+ i 1)(append primes (list i))))))
(define (divisBy l i)
(not (= (length (filter l (lambda (x) (= (modulo i x) 0)))) 0)))
(define (filter lis pred)
(cond ((null? lis) lis)
((pred (car lis)) (cons (car lis)(filter (cdr lis) pred)))
(else (filter (cdr lis) pred))))
(iter 2 ‘()))

(sieve 5)