Primality by trial division: Difference between revisions

Content added Content deleted
Line 650: Line 650:
<lang clojure>(defn divides? [k n] (zero? (mod k n)))</lang>
<lang clojure>(defn divides? [k n] (zero? (mod k n)))</lang>


Simple loop from &nbsp; '''3''' &nbsp; to &nbsp; '''&radic;{{overline|&nbsp;n&nbsp;}} &nbsp;''' with step '''2''':
Testing divisors are in range from &nbsp; '''3''' &nbsp; to &nbsp; '''&radic;{{overline|&nbsp;n&nbsp;}} &nbsp;''' with step '''2''':
<lang clojure>(defn prime? [x]
<lang clojure>(defn prime? [x]
(or (= 2 x)
(or (= 2 x)