Jump to content

Carmichael 3 strong pseudoprimes: Difference between revisions

m
→‎{{header|REXX}}: removed the need for finding the minimum.
(→‎{{header|REXX}}: changed the inner DO loop to be faster, added shortcut calculations, used a flag to suppress blank lines, increased initial prime memoization list, removed 1st version (unsorted list).)
m (→‎{{header|REXX}}: removed the need for finding the minimum.)
Line 801:
/*[↓] prime # memoization array.*/
do p=3 to N by 2; if \isPrime(p) then iterate /*Not prime? Skip.*/
pm=p-1; nps=-p*p; @.=0; min=1e9; max=0 /*some handy-dandy REXX variables.*/
/*[↑] Carmichael #snumbers aren'tare even.odd*/
do h3=2 to pm; g=h3+p /*find Carmichael #s for this P. */
gpm=g*pm; npsh3=((nps//h3)+h3)//h3 /*shortcut stuff. */
Line 812:
if \isPrime(r) then iterate
carms=carms+1 /*bump the Carmichael # counter. */
min=min(min,q); max=max(max,q); @.q=r /*find the maximum, build a list.*/
end /*d*/
end /*h3*/
$=0 /*display a list of some Carm #s.*/
do j=min3 to max by 2; if @.j==0 then iterate; $=1
say '──────── a Carmichael number: ' p times j times @.j
end /*j*/
if $ then say /*show bueatificationbeautification blank line.*/
end /*p*/
 
Cookies help us deliver our services. By using our services, you agree to our use of cookies.