Hi,
I'm trying to write a function that determines if a number is a prime
or not.
I Java I have no problem:
private boolean isPrime(int n) {
for(int j=2; (j*j <= n); j++) if( n % j == 0)
return false; return true;
}
Here is my first shot:
(defn prime? [num]
(loop [i 2]
(if (<= (* i i) num)
false)
(recur (inc i)))
true)
It is not working to be sure :)
Please blow my mind with various implementations.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en