Unprimeable numbers: Difference between revisions
Content added Content deleted
(→{{header|REXX}}: simplified parts of the program, optimized for speed.) |
m (→{{header|REXX}}: optimized the program.) |
||
Line 1,768: | Line 1,768: | ||
/*1─ and 2─digit #'s are all primeable.*/ |
/*1─ and 2─digit #'s are all primeable.*/ |
||
do j=100; if !.j then iterate /*Prime? Unprimeable must be composite*/ |
do j=100; if !.j then iterate /*Prime? Unprimeable must be composite*/ |
||
Lm= length(j) /*obtain the length-1 of the number J. */ |
|||
meat= left(j, |
meat= left(j, Lm) /*obtain the first Lm digits of J. */ |
||
/* [↑] examine the "end" digit of J. */ |
/* [↑] examine the "end" digit of J. */ |
||
do e_=1 for eds; new= meat || ed.e_ /*obtain a different number (than J).*/ |
do e_=1 for eds; new= meat || ed.e_ /*obtain a different number (than J).*/ |
||
Line 1,780: | Line 1,780: | ||
if !.new then iterate j /*This new number a prime? " " */ |
if !.new then iterate j /*This new number a prime? " " */ |
||
end /*f_*/ /* [↑] examine the front digit of J. */ |
end /*f_*/ /* [↑] examine the front digit of J. */ |
||
do a_= 2 |
do a_= 2 for Lm-1 /*traipse through the middle digits. */ |
||
meat= left(j, a_ - 1) /*use a number of left─most dec. digits*/ |
meat= left(j, a_ - 1) /*use a number of left─most dec. digits*/ |
||
rest= substr(j, a_ + 1) /* " " " " right─most " " */ |
rest= substr(j, a_ + 1) /* " " " " right─most " " */ |