Function: calcFunc-fact
calcFunc-fact is an autoloaded and byte-compiled function defined in
calc-comb.el.gz.
Signature
(calcFunc-fact N)
Source Code
;; Defined in /usr/src/emacs/lisp/calc/calc-comb.el.gz
(defun calcFunc-fact (n) ; [I I] [F F] [Public]
(let (temp)
(cond ((Math-integer-negp n)
(if calc-infinite-mode
'(var uinf var-uinf)
(math-reject-arg n 'range)))
((integerp n)
(if (<= n 20)
(aref math-small-factorial-table n)
(math-factorial-iter (1- n) 2 1)))
((and (math-messy-integerp n)
(Math-lessp n 100))
(math-inexact-result)
(setq temp (math-trunc n))
(if (>= temp 0)
(if (<= temp 20)
(math-float (calcFunc-fact temp))
(math-with-extra-prec 1
(math-factorial-iter (1- temp) 2 '(float 1 0))))
(math-reject-arg n 'range)))
((math-numberp n)
(let* ((q (math-quarter-integer n))
(tn (and q (Math-lessp n 1000) (Math-lessp -1000 n)
(1+ (math-floor n)))))
(cond ((and tn (= q 2)
(or calc-symbolic-mode (< (math-abs tn) 20)))
(let ((q (if (< tn 0)
(math-div
(math-pow -2 (- tn))
(math-double-factorial-iter (* -2 tn) 3 1 2))
(math-div
(math-double-factorial-iter (* 2 tn) 3 1 2)
(math-pow 2 tn)))))
(math-mul q (if calc-symbolic-mode
(list 'calcFunc-sqrt '(var pi var-pi))
(math-sqrt-pi)))))
((and tn (>= tn 0) (< tn 20)
(memq q '(1 3)))
(math-inexact-result)
(math-div
(math-mul (math-double-factorial-iter (* 4 tn) q 1 4)
(if (= q 1) (math-gamma-1q) (math-gamma-3q)))
(math-pow 4 tn)))
(t
(math-inexact-result)
(math-with-extra-prec 3
(math-gammap1-raw (math-float n)))))))
((equal n '(var inf var-inf)) n)
(t (calc-record-why 'numberp n)
(list 'calcFunc-fact n)))))