Anonymous user
Erdős-primes: Difference between revisions
m
→{{header|REXX}}: used the correct name for the primes.
(Add Factor) |
m (→{{header|REXX}}: used the correct name for the primes.) |
||
Line 59:
=={{header|REXX}}==
<lang rexx>/*REXX program counts
parse arg n cols . /*get optional number of primes to find*/
if n=='' | n=="," then n= 500 /*Not specified? Then assume default.*/
if cols=='' | cols=="," then cols= 10 /* " " " " "
Ocols= cols; cols= abs(cols) /*Use the absolute value of cols. */
call genP n /*generate all primes under N. */
primes= 0 /*initialize
$= /*a list of
do j=
_= sumDigs(j); if \!._ then iterate /*
primes= primes + 1 /*bump the count of
if Ocols<1 then iterate /*Build the list (to be shown later)? */
$= $ right(j, w) /*add the
if primes//cols\==0 then iterate /*have we populated a line of output? */
say substr($, 2); $= /*display what we have so far (cols). */
Line 78:
if $\=='' then say substr($, 2) /*possible display some residual output*/
say
say 'found ' primes
exit 0 /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
Line 93:
if j//@.k == 0 then iterate j /*÷ by prev. prime? ¬prime ___ */
end /*k*/ /* [↑] only divide up to √ J */
#= # + 1; @.#= j;
end /*j*/
return</lang>
Line 105:
461 463 467 487
found 54
</pre>
|