Fundamentals11 / 11
Up next

loop and recur

;; loop/recur iterates without consuming the stack
(defn factorial [n]
  (loop [i n
         acc 1]
    (if (zero? i)
      acc
      (recur (dec i) (* acc i)))))

(println (factorial 5))
What you're solving

stack-safe iteration