Created
August 18, 2023 01:25
-
-
Save magnomp/7fc9730dfeb5e5d96f3465ceb96d679f to your computer and use it in GitHub Desktop.
Clojure Factorial
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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