Skip to content

Instantly share code, notes, and snippets.

@piyushmaurya23
Last active November 13, 2018 16:41
Show Gist options
  • Save piyushmaurya23/4a0f5b011037a79f56f6 to your computer and use it in GitHub Desktop.
Save piyushmaurya23/4a0f5b011037a79f56f6 to your computer and use it in GitHub Desktop.
4. Define a Recursive LISP function to compute factorial of a given number.
(defun fact(n)
(if (= n 1)
1
(* n (fact (- n 1)))))
@a0309nkita
Copy link

In line 2, shouldn't the if statement's parentheses be paired? Because the recursive code should be outside of the if condition.

if condition finishes after the line just after it,so 4th line ,ie the recursive call is automatically out of the if condition

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment