Last active
November 13, 2018 16:41
-
-
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.
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
(defun fact(n) | |
(if (= n 1) | |
1 | |
(* n (fact (- n 1))))) | |
lijigang
commented
Oct 15, 2017
•
In line 2, shouldn't the if
statement's parentheses be paired? Because the recursive code should be outside of the if
condition.
In line 2, shouldn't the
if
statement's parentheses be paired? Because the recursive code should be outside of theif
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