Miller–Rabin primality test: Difference between revisions

m
→‎{{header|REXX}}: added a comment to the REXX section header.
m (→‎{{header|REXX}}: folded one statement.)
m (→‎{{header|REXX}}: added a comment to the REXX section header.)
Line 2,899:
This would be in the same vein as:
3 is prime, 5 is prime, 7 is prime, all odd numbers are prime.
 
The   '''K'''   (above) is signified by the REXX variable   '''times'''   in the REXX program below.
 
<br>To make the program small, the true &nbsp; prime generator &nbsp; was coded to be small, but not particularly fast.
<lang rexx>/*REXX program puts the Miller─Rabin primality test through its paces. */
parse arg limit accurtimes . /*obtain optional arguments from the CL*/
if limit=='' | limit==',' then limit=1000 /*Not specified? Then use the default.*/
if accurtimes=='' | accurtimes==',' then accurtimes= 10 /* " " " " " " */
numeric digits max(200, 2*limit) /*we're dealing with some ginormous #s.*/
tell= accurtimes<0; pad=left('', 7) /*show primes only if accurtimes is negative*/
accurtimes=abs(accurtimes); w=length(accurtimes) /*use absolute value of ACCURTIMES; get len.*/
call genPrimes limit /*suspenders now, use a belt later ··· */
@MRpt= 'Miller─Rabin primality test' /*define a character literal for SAY. */
say "There are" # 'primes ≤' limit /*might as well display some stuff. */
say /* [↓] (skipping unity); show sep line*/
do a=2 to accurtimes; say copies('─',89) /*(skipping unity) do range of K'sTIMEs. */
mrp=0 /*counter of primes for this pass. */
do z=1 for limit /*now, let's get busy and crank primes.*/