Skip to content

Commit

Permalink
Fixed para.lsp primep primep*
Browse files Browse the repository at this point in the history
  • Loading branch information
sasagawa888 committed May 22, 2024
1 parent 41a8012 commit 574cdbd
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions tests/para.lsp
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
;(mp-create 5)
;(primep* 100000000000031)
(defun primep* (n)
(if (= (mod n 2) 0)
nil
(let* ((limit (isqrt n))
(span (div limit 5)))
(mp-part (coprimep n 3 span)
(coprimep n (near-odd span) (* 2 span ))
(coprimep n (near-odd (* 2 span)) (* 3 span))
(coprimep n (near-odd (* 3 span)) (* 4 span))
(coprimep n (near-odd (* 4 span)) limit)))))
(cond ((= n 2) t)
((= (mod n 2) 0) nil)
(t (let* ((limit (isqrt n))
(span (div limit 5)))
(mp-part (coprimep n 3 span)
(coprimep n (near-odd span) (* 2 span ))
(coprimep n (near-odd (* 2 span)) (* 3 span))
(coprimep n (near-odd (* 3 span)) (* 4 span))
(coprimep n (near-odd (* 4 span)) limit))))))

(defun near-odd (n)
(if (= (mod n 2) 0)
Expand All @@ -25,6 +25,7 @@
(t (coprimep n (+ s 2) e))))

(defun primep (n)
(cond ((= (mod n 2) 0) nil)
(cond ((= n 2) t)
((= (mod n 2) 0) nil)
(t (coprimep n 3 (isqrt n)))))

0 comments on commit 574cdbd

Please sign in to comment.