aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Belanger2007-06-22 01:13:01 +0000
committerJay Belanger2007-06-22 01:13:01 +0000
commit887fc3b8ccaee9842aa3a47575bf1cdc0e92ab37 (patch)
tree72f34f4e238e30b8e5f825c6deb6d8d4de245674
parent1f26c38058f08b2af4188ca41ada1363e61f3be6 (diff)
downloademacs-887fc3b8ccaee9842aa3a47575bf1cdc0e92ab37.tar.gz
emacs-887fc3b8ccaee9842aa3a47575bf1cdc0e92ab37.zip
(math-small-factorial-table): New variable.
(calcFunc-fact): Use `math-small-factorial-table'.
-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 @@
294 294
295;;; Factorial and related functions. 295;;; Factorial and related functions.
296 296
297(defconst math-small-factorial-table
298 (vector 1 1 2 6 24 120 720 5040 40320 362880
299 (math-read-number-simple "3628800")
300 (math-read-number-simple "39916800")
301 (math-read-number-simple "479001600")
302 (math-read-number-simple "6227020800")
303 (math-read-number-simple "87178291200")
304 (math-read-number-simple "1307674368000")
305 (math-read-number-simple "20922789888000")
306 (math-read-number-simple "355687428096000")
307 (math-read-number-simple "6402373705728000")
308 (math-read-number-simple "121645100408832000")
309 (math-read-number-simple "2432902008176640000")))
310
297(defun calcFunc-fact (n) ; [I I] [F F] [Public] 311(defun calcFunc-fact (n) ; [I I] [F F] [Public]
298 (let (temp) 312 (let (temp)
299 (cond ((Math-integer-negp n) 313 (cond ((Math-integer-negp n)
@@ -302,14 +316,7 @@
302 (math-reject-arg n 'range))) 316 (math-reject-arg n 'range)))
303 ((integerp n) 317 ((integerp n)
304 (if (<= n 20) 318 (if (<= n 20)
305 (aref '[1 1 2 6 24 120 720 5040 40320 362880 319 (aref math-small-factorial-table n)
306 (bigpos 800 628 3) (bigpos 800 916 39)
307 (bigpos 600 1 479) (bigpos 800 20 227 6)
308 (bigpos 200 291 178 87) (bigpos 0 368 674 307 1)
309 (bigpos 0 888 789 922 20) (bigpos 0 96 428 687 355)
310 (bigpos 0 728 705 373 402 6)
311 (bigpos 0 832 408 100 645 121)
312 (bigpos 0 640 176 8 902 432 2)] n)
313 (math-factorial-iter (1- n) 2 1))) 320 (math-factorial-iter (1- n) 2 1)))
314 ((and (math-messy-integerp n) 321 ((and (math-messy-integerp n)
315 (Math-lessp n 100)) 322 (Math-lessp n 100))