Anonymous user
Summarize primes: Difference between revisions
m
→{{header|REXX}}: simplified program, added/changed whitespace and comments.
m (added whitespace and a comma.) |
m (→{{header|REXX}}: simplified program, added/changed whitespace and comments.) |
||
Line 1,030:
@.1=2; @.2=3; @.3=5; @.4=7; @.5=11 /*define some low primes. */
!.2=1; !.3=1; !.5=1; !.7=1; !.11=1 /* " " " " flags. */
#=5;
/* [↓] generate more primes ≤ high.*/
do j=@.#+2 by 2 until @.#>=hi & @.#>sP /*find odd primes where P≥hi and P>sP.*/
parse var j '' -1 _; if
if j//3==0 then
do k=5 while sq.k<=j
if j // @.k == 0 then iterate j /*Is J ÷ X? Then not prime. ___ */
end /*k*/ /* [↑] only process numbers ≤ √ J */
#= #+1; @.#= j;
if @.#<hi then sP= sP + @.# /*maybe add this prime to sum─of─primes*/
end /*j*/; return</lang>
{{out|output|text= when using the default inputs:}}
<pre>
|