Anonymous user
Primes whose first and last number is 3: Difference between revisions
Primes whose first and last number is 3 (view source)
Revision as of 14:18, 28 July 2021
, 2 years ago→{{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
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. */
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
end /*j*/;
{{out|output|text= when using the default inputs:}}
<pre>
|