summaryrefslogtreecommitdiff
path: root/lisp/calc/calc-comb.el
diff options
context:
space:
mode:
authorJay Belanger <jay.p.belanger@gmail.com>2007-06-22 01:13:01 +0000
committerJay Belanger <jay.p.belanger@gmail.com>2007-06-22 01:13:01 +0000
commit887fc3b8ccaee9842aa3a47575bf1cdc0e92ab37 (patch)
tree72f34f4e238e30b8e5f825c6deb6d8d4de245674 /lisp/calc/calc-comb.el
parent1f26c38058f08b2af4188ca41ada1363e61f3be6 (diff)
downloademacs-887fc3b8ccaee9842aa3a47575bf1cdc0e92ab37.tar.gz
(math-small-factorial-table): New variable.
(calcFunc-fact): Use `math-small-factorial-table'.
Diffstat (limited to 'lisp/calc/calc-comb.el')
-rw-r--r--lisp/calc/calc-comb.el23
1 files changed, 15 insertions, 8 deletions
diff --git a/lisp/calc/calc-comb.el b/lisp/calc/calc-comb.el
index 6c30177a0b0..46f2e5637e0 100644
--- a/lisp/calc/calc-comb.el
+++ b/lisp/calc/calc-comb.el
@@ -294,6 +294,20 @@
;;; Factorial and related functions.
+(defconst math-small-factorial-table
+ (vector 1 1 2 6 24 120 720 5040 40320 362880
+ (math-read-number-simple "3628800")
+ (math-read-number-simple "39916800")
+ (math-read-number-simple "479001600")
+ (math-read-number-simple "6227020800")
+ (math-read-number-simple "87178291200")
+ (math-read-number-simple "1307674368000")
+ (math-read-number-simple "20922789888000")
+ (math-read-number-simple "355687428096000")
+ (math-read-number-simple "6402373705728000")
+ (math-read-number-simple "121645100408832000")
+ (math-read-number-simple "2432902008176640000")))
+
(defun calcFunc-fact (n) ; [I I] [F F] [Public]
(let (temp)
(cond ((Math-integer-negp n)
@@ -302,14 +316,7 @@
(math-reject-arg n 'range)))
((integerp n)
(if (<= n 20)
- (aref '[1 1 2 6 24 120 720 5040 40320 362880
- (bigpos 800 628 3) (bigpos 800 916 39)
- (bigpos 600 1 479) (bigpos 800 20 227 6)
- (bigpos 200 291 178 87) (bigpos 0 368 674 307 1)
- (bigpos 0 888 789 922 20) (bigpos 0 96 428 687 355)
- (bigpos 0 728 705 373 402 6)
- (bigpos 0 832 408 100 645 121)
- (bigpos 0 640 176 8 902 432 2)] n)
+ (aref math-small-factorial-table n)
(math-factorial-iter (1- n) 2 1)))
((and (math-messy-integerp n)
(Math-lessp n 100))