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; L= length(@.j); z= 0 /*find primes with leading/trailing dig*/
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(13579, substr(@.j, k, 1), 'M')>0 then do; z= z+1; if z>1 then iterate j /* ◄■■■■■■■ the filter.*/
if verify(substr(p, k, 1), 13579, 'M')>0 then do; z= z+1; if z>1 then iterate j /* ◄■■■■■■■ the filter.*/
end
end
end /*k*/
end /*k*/
found= found + 1 /*bump the number of primes found. */
found= found + 1 /*bump the number of primes found. */