```1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 ``` ```; project euler problem 1 (define (one n) (let ((sieve (make-vector n 0))) (do ((i 3 (+ i 3))) ((<= n i)) (vector-set! sieve i i)) (do ((i 5 (+ i 5))) ((<= n i)) (vector-set! sieve i i)) (let loop ((i 0) (sum 0)) (if (= i n) sum (loop (+ i 1) (+ sum (vector-ref sieve i))))))) (display (one 1000)) (newline) (define (two-iter n) (let loop ((i 1) (sum 0)) (cond ((= i n) sum) ((or (zero? (modulo i 3)) (zero? (modulo i 5))) (loop (+ i 1) (+ sum i))) (else (loop (+ i 1) sum))))) (display (two-iter 1000)) (newline) (define (two-recur n) (cond ((zero? n) 0) ((or (zero? (modulo n 3)) (zero? (modulo n 5))) (+ n (two-recur (- n 1)))) (else (two-recur (- n 1))))) (display (two-recur 999)) (newline) (define (three n) (define (gauss n) (* n (+ n 1) 1/2)) (+ (* 3 (gauss (quotient n 3))) (* 5 (gauss (quotient n 5))) (- (* 15 (gauss (quotient n 15)))))) (display (three 999)) (newline) ```
 ```1 2 3 4 ``` ```233168 233168 233168 233168 ```