Truncatable primes: Difference between revisions
Content deleted Content added
m →{{header|REXX}}: added/changed whitespace and comments. |
m →{{header|REXX}}: simplfied two search loops. |
||
Line 2,073: | Line 2,073: | ||
end /*j*/ |
end /*j*/ |
||
/* [↓] find largest left truncatable P*/ |
/* [↓] find largest left truncatable P*/ |
||
do L=# by -1 for #; |
do L=# by -1 for #; digs=length(@.L) /*search from top end; get the length.*/ |
||
do k=1 for |
do k=1 for digs; _=right(@.L, k) /*validate all left truncatable primes.*/ |
||
if \!._ then iterate L /*Truncated number not prime? Skip it.*/ |
if \!._ then iterate L /*Truncated number not prime? Skip it.*/ |
||
end /*k*/ |
end /*k*/ |
||
leave /* |
leave /*egress, found left truncatable prime.*/ |
||
end /*L*/ |
end /*L*/ |
||
/* [↓] find largest right truncated P.*/ |
/* [↓] find largest right truncated P.*/ |
||
do R=# by -1 for #; |
do R=# by -1 for #; digs=length(@.R) /*search from top end; get the length.*/ |
||
do k=1 for |
do k=1 for digs; _=left(@.R, k) /*validate all right truncatable primes*/ |
||
if \!._ then iterate R /*Truncated number not prime? Skip it.*/ |
if \!._ then iterate R /*Truncated number not prime? Skip it.*/ |
||
end /*k*/ |
end /*k*/ |
||
leave /* |
leave /*egress, found right truncatable prime*/ |
||
end /*R*/ |
end /*R*/ |
||
/* [↓] show largest left/right trunc P*/ |
/* [↓] show largest left/right trunc P*/ |