Skip to main content
added 8 characters in body
Source Link

I am a beginner to Clojure and I made a little script that prints out every prime number from 1 to 1000. Let me know if there are any improvements that I can make:

(loop [i 2]
  (loop [j 2]
    (ifwhen (= j i)
      (println i)())
    (ifwhen-not (= (mod i j) 0)()
          (recur (inc j))))
  (ifwhen (< i 1000)
    (recur (inc i))()))

I am a beginner to Clojure and I made a little script that prints out every prime number from 1 to 1000. Let me know if there are any improvements that I can make:

(loop [i 2]
  (loop [j 2]
    (if (= j i)
      (println i)())
    (if (= (mod i j) 0)()
      (recur (inc j))))
  (if (< i 1000)
    (recur (inc i))()))

I am a beginner to Clojure and I made a little script that prints out every prime number from 1 to 1000. Let me know if there are any improvements that I can make:

(loop [i 2]
  (loop [j 2]
    (when (= j i)
      (println i))
    (when-not (= (mod i j) 0)
          (recur (inc j))))
  (when (< i 1000)
    (recur (inc i))))
edited tags
Link
200_success
  • 144.2k
  • 22
  • 188
  • 473
Source Link

Clojure Prime Numbers from 1 to 1000

I am a beginner to Clojure and I made a little script that prints out every prime number from 1 to 1000. Let me know if there are any improvements that I can make:

(loop [i 2]
  (loop [j 2]
    (if (= j i)
      (println i)())
    (if (= (mod i j) 0)()
      (recur (inc j))))
  (if (< i 1000)
    (recur (inc i))()))