Anonymous user
Consecutive primes with ascending or descending differences: Difference between revisions
Consecutive primes with ascending or descending differences (view source)
Revision as of 21:25, 10 August 2021
, 2 years ago→{{header|REXX}}: added/changed whitespace and comments, optimized the GENP subroutine.
(Promoted to a Task) |
m (→{{header|REXX}}: added/changed whitespace and comments, optimized the GENP subroutine.) |
||
Line 738:
end /*j*/; return
/*──────────────────────────────────────────────────────────────────────────────────────*/
genP:
/* [↓] generate more primes ≤ high.*/
do j=@.#+2 by 2 to hi; parse var j '' -1
if j// 7==0 then
if j//13==0 then
do k=8 while
if j // @.k == 0 then iterate j /*Is J ÷ X? Then not prime. ___ */
end /*k*/ /* [↑] only process numbers ≤ √ J */
#= #+1; @.#= j;
end /*j*/; return
/*──────────────────────────────────────────────────────────────────────────────────────*/
show: parse arg ?; if ? then AorD= 'ascending' /*choose which literal for display.*/
else AorD= 'descending' /* " " " " " */
if cols>0 then say '───────┴'center("" , 1 + cols*(w+1), '─')
{{out|output|text= when using the default inputs:}}
<pre>
Line 779 ⟶ 777:
───────┼───────────────────────────────────────────────────────────────────────────────────────────────────────────────
1 │ 128,981 128,983 128,987 128,993 129,001 129,011 129,023 129,037
───────┴───────────────────────────────────────────────────────────────────────────────────────────────────────────────
8 was the longest run of consecutive primes whose differences between primes are strictly ascending and < 1,000,000
Line 787 ⟶ 786:
───────┼───────────────────────────────────────────────────────────────────────────────────────────────────────────────
1 │ 322,171 322,193 322,213 322,229 322,237 322,243 322,247 322,249
───────┴───────────────────────────────────────────────────────────────────────────────────────────────────────────────
8 was the longest run of consecutive primes whose differences between primes are strictly descending and < 1,000,000
|