Anonymous user
Erdős-primes: Difference between revisions
m
→{{header|REXX}}: added code to support showing the largetst Erdos prime < one million.
m (added highest < 1,000,000 comment) |
m (→{{header|REXX}}: added code to support showing the largetst Erdos prime < one million.) |
||
Line 275:
if n=='' | n=="," then n= 2500 /*Not specified? Then assume default.*/
if cols=='' | cols=="," then cols= 10 /* " " " " " */
call genP n /*generate all primes under N. */
w= 10 /*width of a number in any column. */
if cols>0 then say ' index │'center(" Erdos primes that are < " n, 1 + cols*(w+1) )
Line 282 ⟶ 283:
Eprimes= 0; idx= 1 /*initialize # of additive primes & idx*/
$= /*a list of additive primes (so far). */
if $\=='' then say center(idx, 7)"│" substr($, 2) /*possible display residual output.*/
say
say 'found ' commas(Eprimes
say
if nn<0 then say commas(EprimeL) ' is the ' commas(Eprimes)th(Eprimes) " Erdos prime."
exit 0 /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
commas: parse arg ?; do jc=length(?)-3 to 1 by -3; ?=insert(',', ?, jc); end; return ?
facts: arg x;
th: parse arg th; return word('th st nd rd', 1+(th//10) *(th//100%10\==1) *(th//10<4))
/*──────────────────────────────────────────────────────────────────────────────────────*/
genP: parse arg n; @.=.; @.1=2; @.2=3; @.3=5; @.4=7; @.5=11; @.6=13; @.7=17; #= 7
Line 327 ⟶ 331:
found 25 Erdos primes < 2500
</pre>
{{out|output|text= when using the inputs if: <tt 1000000 0 </tt>}}
<pre>
found 7,875 Erdos primes < 1,000,000
999,721 is the 7,875th Erdos prime.
</pre>
|