Anonymous user
Extra primes: Difference between revisions
m
→{{header|REXX}}: changed the GENP function.
(Added Sidef) |
m (→{{header|REXX}}: changed the GENP function.) |
||
Line 1,874:
end /*while*/; return r
/*──────────────────────────────────────────────────────────────────────────────────────*/
genP:
!.=0; !.2=1; !.3=1; !.5=1; !.7=1; !.11=1; !.13
high= max(9 * digits(), iSqrt(hi) ) /*enough primes for sums & primality ÷ */
do j=@.#+4 by 2 while #<=high /*continue on with the next odd prime. */
parse var j '' -1 _ /*obtain the last digit of the J var.*/
if
if j
/* [↓] divide by the primes. ___ */
do k=6 to # while
if j//@.k == 0 then iterate j /*÷ by prev. prime? ¬prime ___ */
end /*k*/ /* [↑] only divide up to √ J */
#=#+1; @.#= j;
end /*j*/
hP= @.#; return # /*hP: is the highest prime generated. */</lang>
|