Advertisement
Guest User

Nikelandjelo

a guest
Feb 7th, 2010
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 0.54 KB | None | 0 0
  1. (defn take-potential-divisors [p coll]
  2.         "Takes only those number from coll, whose square less or equal than p"
  3.         (take-while #(>= p (* % %)) coll))
  4. (defn prime? [p coll]
  5.     "Test whether p is prime or not. coll - prime numbers less than p"
  6.     (nil? (some #(zero? (rem p %)) (take-potential-divisors p coll))))
  7. (def primes (lazy-cat [2 3]
  8.         (filter #(prime? % primes)
  9.                 (range 5 100))))
  10. primes
  11. ;; -> 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