Given a range of integers by its lower and upper limit, construct a list of all prime numbers in that range.
Example:
(deftest p39-primes-range (is (= '(7 11 13 17 19 23 29 31) (primes-range 7 31))))
Solution:
This is a quick one. As we have already defined a lazy seq of prime numbers to solve P35 we can reuse that. To produce the desired range drop from that sequence until we reach the lower bound and then take until we reach the upper bound. Have a look at the solution if this was too terse.
No comments:
Post a Comment