Chernick's Carmichael numbers: Difference between revisions
Content added Content deleted
(Added reference to library.) |
|||
Line 782: | Line 782: | ||
=={{header|Nim}}== |
=={{header|Nim}}== |
||
{{libheader|bignum}} |
|||
Until a(9) a simple primality test using divisions by odd numbers is sufficient. But for a(10), it is necessary to improve the test. We have used here some optimizations found in other solutions: |
Until ''a(9)'' a simple primality test using divisions by odd numbers is sufficient. But for ''a(10)'', it is necessary to improve the test. We have used here some optimizations found in other solutions: |
||
:– eliminating multiples of 3, 5, 7, 11, 13, 17, 19, 23; |
:– eliminating multiples of 3, 5, 7, 11, 13, 17, 19, 23; |
||
:– using a probability test which implies to use big integers; so, we have to convert the number |
:– using a probability test which implies to use big integers; so, we have to convert the tested number to a big integer; |
||
:– for n >= 5, checking only values of m which are multiple of 5 (in fact, we check only the multiples of 5 × 2^(n-4). |
:– for ''n'' >= 5, checking only values of ''m'' which are multiple of 5 (in fact, we check only the multiples of 5 × 2^(''n''-4). |
||
With these optimizations, the program executes in 4-5 minutes. |
With these optimizations, the program executes in 4-5 minutes. |