summaryrefslogtreecommitdiff
path: root/lisp/calc/calc-comb.el
diff options
context:
space:
mode:
authorJay Belanger <jay.p.belanger@gmail.com>2007-06-24 14:30:14 +0000
committerJay Belanger <jay.p.belanger@gmail.com>2007-06-24 14:30:14 +0000
commit40cddce8bd63f840f17a1fbe72c68ead91dcd3c7 (patch)
tree917787077c36ca70464576508500087caffc64ac /lisp/calc/calc-comb.el
parent2793c9bb612afd0d80ca3f9874798cc1247db24a (diff)
downloademacs-40cddce8bd63f840f17a1fbe72c68ead91dcd3c7.tar.gz
emacs-40cddce8bd63f840f17a1fbe72c68ead91dcd3c7.tar.bz2
emacs-40cddce8bd63f840f17a1fbe72c68ead91dcd3c7.zip
(math-init-random-base,math-prime-test): Use math-read-number-simple
to insert constants. (math-prime-test): Redo calculation of sum.
Diffstat (limited to 'lisp/calc/calc-comb.el')
-rw-r--r--lisp/calc/calc-comb.el42
1 files changed, 29 insertions, 13 deletions
diff --git a/lisp/calc/calc-comb.el b/lisp/calc/calc-comb.el
index d4d2ce19528..515995a2e74 100644
--- a/lisp/calc/calc-comb.el
+++ b/lisp/calc/calc-comb.el
@@ -560,9 +560,15 @@
nil
(if (Math-integerp var-RandSeed)
(let* ((seed (math-sub 161803 var-RandSeed))
- (mj (1+ (math-mod seed '(bigpos 0 0 1))))
- (mk (1+ (math-mod (math-quotient seed '(bigpos 0 0 1))
- '(bigpos 0 0 1))))
+ (mj (1+ (math-mod seed
+ (eval-when-compile
+ (math-read-number-simple "1000000")))))
+ (mk (1+ (math-mod (math-quotient
+ seed
+ (eval-when-compile
+ (math-read-number-simple "1000000")))
+ (eval-when-compile
+ (math-read-number-simple "1000000")))))
(i 0))
(setq math-random-table (cons 'vec (make-list 55 mj)))
(while (<= (setq i (1+ i)) 54)
@@ -811,7 +817,9 @@
(error "Argument must be an integer"))
((Math-integer-negp n)
'(nil))
- ((Math-natnum-lessp n '(bigpos 0 0 8))
+ ((Math-natnum-lessp n
+ (eval-when-compile
+ (math-read-number-simple "8000000")))
(setq n (math-fixnum n))
(let ((i -1) v)
(while (and (> (% n (setq v (aref math-primes-table
@@ -824,15 +832,23 @@
((not (equal n (car math-prime-test-cache)))
(cond ((= (% (nth 1 n) 2) 0) '(nil 2))
((= (% (nth 1 n) 5) 0) '(nil 5))
- (t (let ((dig (cdr n)) (sum 0))
- (while dig
- (if (cdr dig)
- (setq sum (% (+ (+ sum (car dig))
- (* (nth 1 dig) 1000))
- 111111)
- dig (cdr (cdr dig)))
- (setq sum (% (+ sum (car dig)) 111111)
- dig nil)))
+ (t (let ((q n) (sum 0))
+ (while (not (eq q 0))
+ (setq sum (%
+ (+
+ sum
+ (calcFunc-mod
+ q
+ (eval-when-compile
+ (math-read-number-simple
+ "1000000"))))
+ 111111))
+ (setq q
+ (math-quotient
+ q
+ (eval-when-compile
+ (math-read-number-simple
+ "1000000")))))
(cond ((= (% sum 3) 0) '(nil 3))
((= (% sum 7) 0) '(nil 7))
((= (% sum 11) 0) '(nil 11))