mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-07-08 21:47:33 +02:00
Fixing over-optimistic shortcut in factor.
This commit is contained in:
parent
347db3fb7d
commit
3ff62dc355
2 changed files with 4 additions and 1 deletions
|
@ -181,10 +181,12 @@
|
|||
(else
|
||||
(let lp ((i 3) (n n) (limit limit) (res res))
|
||||
(cond
|
||||
((= n 1)
|
||||
(reverse res))
|
||||
((> i limit)
|
||||
(reverse (cons n res)))
|
||||
((zero? (remainder n i))
|
||||
(lp i (quotient n i) (quotient limit i) (cons i res)))
|
||||
(lp i (quotient n i) limit (cons i res)))
|
||||
(else
|
||||
(lp (+ i 2) n limit res))))))))))
|
||||
|
||||
|
|
|
@ -68,6 +68,7 @@
|
|||
(test '(2 5) (factor 10))
|
||||
(test '(11) (factor 11))
|
||||
(test '(2 2 3) (factor 12))
|
||||
(test '(3 3 3 5 7) (factor 945))
|
||||
|
||||
(do ((i 3 (+ i 2)))
|
||||
((>= i 101))
|
||||
|
|
Loading…
Add table
Reference in a new issue