Substring primes: Difference between revisions

m
→‎{{header|REXX}}: (to avoid name calling) elided primality test counting
(add FreeBASIC)
m (→‎{{header|REXX}}: (to avoid name calling) elided primality test counting)
Line 194:
if verify(x2, 25 , 'M')>0 then iterate /* " X2 part " " " " " */
L= length(x) /*obtain the length of the X prime.*/
ptests= ptests + 1 /*bump count of the # primality tests. */
do k=1 for L-1 /*test for primality for all substrings*/
do m=k+1 to L; y= substr(x, k, m-1) /*extract a substring from the X prime.*/
ptests= ptests + 1 /*bump count of the # primality tests. */
if \!.y then iterate j /*does substring of X not prime? Skip.*/
end /*m*/
Line 207 ⟶ 205:
if $\=='' then say center(1,7)"│" substr($, 2) /*display the list of substring primes.*/
say; say 'Found ' words($) @sprs
say; say ptests ' primality tests were performed.'
exit 0 /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
Line 232 ⟶ 229:
 
Found 9 primes (base ten) where all substrings are also primes < 500
 
14 primality tests were performed.
</pre>