Created
August 28, 2012 16:25
-
-
Save omegatakuma/3499948 to your computer and use it in GitHub Desktop.
エラトステネスの篩
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define (prime n) | |
(let loop ((lst (iota (- n 1) 2))(result '())) | |
(let ((solve (cons (car lst) result))) | |
(if (< (last lst) (* (car solve) (car solve))) | |
(append (reverse result) lst) | |
(loop (remove (^(x)(zero? (remainder x (car lst)))) lst) solve))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment