Anonymous user
Carmichael 3 strong pseudoprimes: Difference between revisions
Carmichael 3 strong pseudoprimes (view source)
Revision as of 16:29, 27 September 2014
, 9 years ago→{{header|REXX}}: changed some comments, used better variable names, optimized some code.
m (→{{header|REXX}}: restricted search list (for output) to start with the current prime.) |
m (→{{header|REXX}}: changed some comments, used better variable names, optimized some code.) |
||
Line 787:
=={{header|REXX}}==
Note that REXX's version of '''modulus''' (<big><code>'''//'''</code></big>) is really a ''remainder'' function,
<br>so a version of the '''modulus''' function was hard-coded below.
<br>(It was necessary to use '''modulus''' instead of '''remainder''' when using a negative value.)
<br>The Carmichael numbers are shown in numerical order.
<br>Some code optimization was done, while not necessary for the small default number (<code>61</code>), it was significant for larger numbers.
<lang rexx>/*REXX program calculates Carmichael 3-strong pseudoprimes (up to N).*/
numeric digits 30 /*in case user wants bigger nums.*/
Line 800 ⟶ 801:
!.=0; !.2=1; !.3=1; !.5=1; !.7=1; !.11=1; !.13=1; !.17=1; !.19=1; !.23=1
/*[↓] prime # memoization array.*/
do p=3 to N by 2; if \isPrime(p) then iterate /*Not prime? Skip
pm=p-1;
do h3=2 to pm; g=h3+p /*find Carmichael #s for this P. */
do d=1 for g-1▼
if
/*find the maximum.
end /*d*/ /* [↑] find minimum and maximum.*/
$=0 /*display a list of some Carm #s.*/
do j=
say '──────── a Carmichael number: ' p times j times @.j
end /*j*/
|