Jump to content

Primality by trial division: Difference between revisions

Line 652:
<lang clojure>(defn prime? [x]
(or (= 2 x)
(= 3 x)
(and (< 1 x)
(odd? x)
(not-any? (partial divides? x)
(range 3 (inc (Math/sqrt x)) 2)))))</lang>
</lang>
 
Testing only prime divisors:
Cookies help us deliver our services. By using our services, you agree to our use of cookies.