Jump to content

Miller–Rabin primality test: Difference between revisions

→‎{{header|REXX}}: added more whitespace, simplified some statements.
m (→‎{{header|REXX}}: added/changed whitespace and comments, change indentations in program and output, simplified the genPrimes subroutine..)
(→‎{{header|REXX}}: added more whitespace, simplified some statements.)
Line 2,906:
if accur=='' | accur==',' then accur= 10 /* " " " " " " */
numeric digits max(200, 2*limit) /*we're dealing with some ginormous #s.*/
tell= accur<0; pad=left('', 7) /*show primes only if K accur is negative.*/
accur=abs(accur); w=length(accur) /*now, use the absolute value of ACCUR; Kget len. */
call genPrimes limit /*suspenders now, use a belt later ··· */
primePi=#; @MRpt= 'Miller─Rabin primality test' /*savedefine counta ofcharacter actualliteral primes;for literal SAY. */
say "There are" primePi # 'primes ≤' limit /*might as well display some stuff. */
say /*nothing wrong with some whitespace. */
do a=2 to accur /*(skipping unity) do range of K's. */
Line 2,919:
if p==0 then iterate /*Not prime? Then try another number.*/
mrp=mrp+1 /*well, found another one, by gum! */
if tell then say z 'is prime according to' @MRpt "with K="a
if !.z then iterate
say '[K='a"] " z "isn't prime !" /*oopsy─doopsy and/or whoopsy─daisy !*/
end /*z*/
 
say ' for 1──►'limit", K="right(a,length(accur))',',
say pad 'for 1──►'limit", K="right(a,w)',' @MRpt "found" mrp 'primes {out of' primePi#"}."
end /*a*/
exit /*stick a fork in it, we're all done. */
Cookies help us deliver our services. By using our services, you agree to our use of cookies.