-
-
Save tshatrov/86ecefc504b4daad43d9d670f3387551 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(let* ((target 600851475143) ;; number to factorize | |
(n (floor (sqrt target))) ;; size of sieve | |
) | |
(loop named outer | |
with arr = (make-array n :initial-element nil) | |
for i from 2 below n | |
unless (aref arr i) | |
do (loop for j from i below n by i do (setf (aref arr j) i)) | |
(loop while (zerop (mod target i)) | |
do (format t "~a ~a~%" target i) | |
if (= target i) do (return-from outer target) else do (setf target (/ target i))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment