Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defn take-potential-divisors [p coll]
- "Takes only those number from coll, whose square less or equal than p"
- (take-while #(>= p (* % %)) coll))
- (defn prime? [p coll]
- "Test whether p is prime or not. coll - prime numbers less than p"
- (nil? (some #(zero? (rem p %)) (take-potential-divisors p coll))))
- (def primes (lazy-cat [2 3]
- (filter #(prime? % primes)
- (range 5 100))))
- primes
- ;; -> 2 3 5 7 11 13 17 19 23 25 29 31 35 37 41 43 47 53 59 61 67 71 73 79 83 89 97 but 25 and 35 aren't primes
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement