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 and shows/displays the number of Erdősadditive primes under a specified number N. */
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 the number of Erdősadditive primes.*/
$= /*a list of Erdősadditive primes (so far). */
do j=12 until j>=n; if \!.j then iterate /*Is J not a prime? No, Thenthen skip it. */
_= sumDigs(j); if \!._ then iterate /*Isis sum of J's digs a prime? No, skip.*/
primes= primes + 1 /*bump the count of Erdősadditive primes. */
if Ocols<1 then iterate /*Build the list (to be shown later)? */
$= $ right(j, w) /*add the Erdősadditive prime to the $ list. */
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 " Erdősadditive primes < " n
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; !.j= 1 /*bump prime count; assign prime & flag*/
end /*j*/
return</lang>
Line 105:
461 463 467 487
 
 
found 54 Erdősadditive primes < 500
</pre>