write a program in lisp in AI for finding factorial of number?
sumera a
2007-07-11 10:41:33 UTC
Lisp is programing language which is Artificial intellegence
Three answers:
Truly W
2007-07-14 11:50:00 UTC
;;; A function to calculate the factorial of a positive integer.
(defun facto (n)
(if (= n 1)
1
(* n (facto (- n 1)) )
)
)
pellicone
2016-12-13 00:47:43 UTC
Factorial In Lisp
2016-03-19 10:13:59 UTC
although husaki given the correct ans, im just giving the code ur code will not work as every time (in the loop) ur assigning a new value (a) to f... try this int fact(int a) { int result=1,counter; for(counter=1;counter<=a;counter++) { result*=counter; } return result; } }
ⓘ
This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.