Skip to content

Instantly share code, notes, and snippets.

@magnomp
Created August 18, 2023 01:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save magnomp/7fc9730dfeb5e5d96f3465ceb96d679f to your computer and use it in GitHub Desktop.
Save magnomp/7fc9730dfeb5e5d96f3465ceb96d679f to your computer and use it in GitHub Desktop.
Clojure Factorial
(ns hello)
(defn factorial
"Calcula o fatorial do numero dado"
[n]
(loop [i n acc 1]
(if (= i 1)
acc
(recur (- i 1) (* acc i)))))
(println (factorial 6))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment