binomial coefficient, factorial lisp
Posted: Fri Jun 08, 2012 7:49 am
Hi,
i´m a newbie in lisp,
(sorry, my english is not so good,
because i didn´t found a forum in my country, just for Python, C++, Java etc...)
so my problem is, i try to programm a programm in lisp, that calculate binomial coefficient with factorial function(iterative ) NOT recursive...
i´ve try everthing, but my programm doesn´t work...
(i tried with global function, local function (factorial)), but evertime got an error
and one more question:
how to compile in emacs???
(i tried in in *scatch* => (load "binom-coef.el")
but also an error message)
Many thanks,
inka
i´m a newbie in lisp,
(sorry, my english is not so good,
because i didn´t found a forum in my country, just for Python, C++, Java etc...)
so my problem is, i try to programm a programm in lisp, that calculate binomial coefficient with factorial function(iterative ) NOT recursive...
i´ve try everthing, but my programm doesn´t work...
(i tried with global function, local function (factorial)), but evertime got an error
Code: Select all
(defun binom-coef(a b)
(if (or (< a b) (< b 0))
nil ) ;
(flet fakul(n) ;factorial
(cond ((= n 0) 1)
(t (* n (fakul (- n 1))))))
(/ (fakul a) (* (fakul b) (fakul(- a b)))))
and one more question:
how to compile in emacs???
(i tried in in *scatch* => (load "binom-coef.el")
but also an error message)
Many thanks,
inka