Primes which contain only one odd digit: Difference between revisions
Content added Content deleted
(→{{header|Wren}}: Added stretch goal.) |
m (→{{header|REXX}}: optimized the filter.) |
||
Line 121: | Line 121: | ||
found= 0; idx= 1 /*initialize # of primes found; IDX. */ |
found= 0; idx= 1 /*initialize # of primes found; IDX. */ |
||
$= /*list of primes that contain a string.*/ |
$= /*list of primes that contain a string.*/ |
||
do j=2 for #-1; |
do j=2 for #-1; p= @.j; L= length(p) /*find primes with leading/trailing dig*/ |
||
z= 0 |
|||
do k=L by -1 for L |
do k=L by -1 for L |
||
if verify( |
if verify(substr(p, k, 1), 13579, 'M')>0 then do; z= z+1; if z>1 then iterate j /* ◄■■■■■■■ the filter.*/ |
||
end |
|||
end /*k*/ |
end /*k*/ |
||
found= found + 1 /*bump the number of primes found. */ |
found= found + 1 /*bump the number of primes found. */ |