Skip to content

Commit

Permalink
Added Project 07 Benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
zolrath committed Aug 25, 2011
1 parent 4e13595 commit bf182c7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Benchmarks
+ [**04**](http://projecteuler.net/index.php?section=problems&id=4) run time: *180.087667 ms*
+ [**05**](http://projecteuler.net/index.php?section=problems&id=5) run time: *28.710344 ms*
+ [**06**](http://projecteuler.net/index.php?section=problems&id=6) run time: *35.821500 us*
+ [**07**](http://projecteuler.net/index.php?section=problems&id=7) run time: *646.998008 ms*
+ [**10**](http://projecteuler.net/index.php?section=problems&id=10) run time: *252.114590 ms (originally: 117.555661 seconds)*
+ [**11**](http://projecteuler.net/index.php?section=problems&id=11) run time: *238.403763 ms*
+ [**21**](http://projecteuler.net/index.php?section=problems&id=21) run time: *13.299193 sec*
Expand Down
10 changes: 10 additions & 0 deletions src/euler/07.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
(ns euler.07
(:use [euler.core]
[criterium.core]))

(defn nth-prime [n]
(nth (filter is-prime? (range)) (dec n)))

(defn solve07 []
"Lists the 10,001st prime number"
(nth-prime 10001))
2 changes: 1 addition & 1 deletion src/euler/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

(defn is-prime? [n]
"Returns true if given number is prime"
(and (not (zero? (mod n 2))) (zero? (count (filter #(zero? (rem n %)) (range 3 (inc (sqrt n)) 2))))))
(zero? (count (filter #(zero? (rem n %)) (range 3 (inc (sqrt n)) 2)))))

(defn primes-to [n]
"Returns a list of all primes from 2 to n"
Expand Down

0 comments on commit bf182c7

Please sign in to comment.