Funding Circle coding challenge
To run:
$ lein run
No options are accepted.
-
Consider complexity.
-
How fast does your code run?
This code takes about 20 seconds to run on my laptop, but the majority of the time spent is due to JVM/Clojure startup.
-
How does it scale?
There is a nested
reduce
, which will scale poorly for larger tables (in hundreds or greater) due not to duplication of multiplication operations, but for inefficient string operations.Also, in choosing to use the Sieve of Eratosthenes, as primes are discovered, memory usage will increase. However, this reduces CPU usage by avoiding any division operations.
-
Consider cases where we want N primes.
When N primes are desired, change the argument passed to
primes
.
Copyright © 2018 Matthew Batema
Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.