Created
August 10, 2023 18:37
-
-
Save primo-ppcg/0258c6f20308216d78cb3169d5cff558 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
(use spork/test) | |
(use spork/math) | |
(def pseudoprimes | |
[1373653 | |
1530787 | |
1987021 | |
2284453 | |
3116107 | |
5173601 | |
6787327 | |
11541307 | |
13694761 | |
15978007 | |
16070429 | |
16879501 | |
25326001 | |
27509653 | |
27664033 | |
28527049 | |
54029741 | |
61832377 | |
66096253 | |
74927161 | |
80375707 | |
101649241 | |
161304001 | |
960946321 | |
1157839381 | |
3215031751 | |
3697278427 | |
5764643587 | |
6770862367 | |
14386156093 | |
15579919981 | |
18459366157 | |
19887974881 | |
21276028621 | |
27716349961 | |
29118033181 | |
37131467521 | |
41752650241 | |
42550716781 | |
43536545821 | |
118670087467 | |
307768373641 | |
315962312077 | |
354864744877 | |
457453568161 | |
528929554561 | |
546348519181 | |
602248359169 | |
1362242655901 | |
1871186716981 | |
2152302898747 | |
2273312197621 | |
2366338900801 | |
3343433905957 | |
3461715915661 | |
3474749660383 | |
3477707481751 | |
4341937413061 | |
4777422165601 | |
5537838510751]) | |
(defn check-factor [n res] | |
(assert (all prime? res)) | |
(assert (all = res (sorted res))) | |
(assert (= n (* ;res)))) | |
(each n pseudoprimes (check-factor n (factor n))) | |
(for n 1 100000 (check-factor n (factor n))) | |
(timeit-loop [:timeout 1 n :in pseudoprimes] | |
"pseudoprimes " | |
(factor n)) | |
(timeit-loop [n :range [1 100000]] | |
"small integers" | |
(factor n)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment