Substring primes: Difference between revisions

m
→‎{{header|REXX}}: changed some comments, simplified the code.
(Added Sidef)
m (→‎{{header|REXX}}: changed some comments, simplified the code.)
Line 464:
say ' index │'center(title, 1 + cols*(w+1) ) /*display the title of the output. */
say '───────┼'center("" , 1 + cols*(w+1), '─') /* " " separator " " " */
found= 0; idx= 1 /*initializedefine # of nicesubstring primes andfound; indexIDX.*/
$= /*a list of substring primes (so far). */
do j=1 for #; x= @.j; x2= substr(x, 2) /*search for primes that fit criteria. */
Line 476:
end /*k*/
 
found= found + 1 /*bump the number of nice substring primes. */
if$= cols<0$ right( commas(j), w) then iterate /*Buildadd thea listsubstring prime (to be──► shown later)?$ list. */
c= commas(j) /*maybe add commas to the number. */
$= $ right(c, max(w, length(c) ) ) /*add a nice prime ──► list, allow big#*/
if found//cols\==0 then iterate /*have we populated a line of output? */
say center(idx, 7)'│' substr($, 2); $= /*display what we have so far (cols). */
Line 501 ⟶ 499:
if j// 3==0 then iterate /*" " " 3? */
if j// 7==0 then iterate /*" " " 7? */
/* [↑] the above 3 lines saves time.*/
do k=5 while s.k<=j /* [↓] divide by the known odd primes.*/
if j // @.k == 0 then iterate j /*Is J ÷ X? Then not prime. ___ */