if (n == 0) return the "factorial", else go to the "loop label" and recur with the two parameters (n--) and (factorial * n). Go on until n-- reaches 0.
In a Java-like translation we could have: int n = number; factorial = 1; while(n > 0){ factorial *= n--; } return factorial; On Sun, Apr 15, 2012 at 5:37 PM, Anto <anto.aravinth....@gmail.com> wrote: > Can anyone explain me what does the last three lines > does: > > (loop [n number factorial 1] > (if (zero? n) > factorial (recur (dec n) (* factorial n)))) > > Thanks in advance. > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en