Primes whose first and last number is 3: Difference between revisions

m
→‎{{header|REXX}}: changed a comment, elided the use of the prime semaphores.
m (→‎{{header|REXX}}: changed a comment, elided the use of the prime semaphores.)
Line 348:
 
Also,   if a negative   '''cols'''   is specified,   only the   ''count''   of primes found is shown.
<lang ringrexx>/*REXX pgm finds and displays primes (base ten) that contain a leading and trailing 3. */
parse arg hi cols dig . /*obtain optional argument from the CL.*/
if hi=='' | hi=="," then hi= 4000 /*Not specified? Then use the default.*/
Line 383:
/*──────────────────────────────────────────────────────────────────────────────────────*/
genP: @.1=2; @.2=3; @.3=5; @.4=7; @.5=11 /*define some low primes. */
!.=0; !.2=1; !.3=1; !.5=1; !.7=1; !.11=1 /* " " " #=5; " sq.#= @.# **2 semaphores./*number of primes so far; prime square*/
#=5; sq.#= @.# **2 /*number of primes so far; prime². */
do j=@.#+2 by 2 to hi-1 /*find odd primes from here on. */
parse var j '' -1 _; if _==5 then iterate /*J divisible by 5? (right dig)*/
Line 392 ⟶ 391:
if j // @.k == 0 then iterate j /*Is J ÷ X? Then not prime. ___ */
end /*k*/ /* [↑] only process numbers ≤ √ J */
#= #+1; @.#= j; sq.#= j*j; !.j= 1 /*bump # of Ps; assign next P; P²; P# square*/
end /*j*/; return</lang>
{{out|output|text=&nbsp; when using the default inputs:}}
<pre>