Skip to content

Instantly share code, notes, and snippets.

@rinfz
Created March 9, 2015 23:38
Show Gist options
  • Save rinfz/4c62e4fa08fee85e4350 to your computer and use it in GitHub Desktop.
Save rinfz/4c62e4fa08fee85e4350 to your computer and use it in GitHub Desktop.
(define (is-prime n)
(if (<= n 3)
(>= n 2)
(if (or (= (modulo n 2) 0) (= (modulo n 3) 0))
#f
(do ((i 5 (+ i 6))) ((> i (+ (sqrt n) 1)))
(if (or (= (modulo n i) 0) (= (modulo n (+ i 2)) 0))
#f))) #t))
(define (main args)
(display (is-prime 2)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment