Anonymous user
Twin primes: Difference between revisions
m
→{{header|REXX}}: optimized the GENP function.
SqrtNegInf (talk | contribs) (Added Perl entry) |
m (→{{header|REXX}}: optimized the GENP function.) |
||
Line 611:
/*──────────────────────────────────────────────────────────────────────────────────────*/
genP: arg y; @.1=2; @.2=3; @.3=5; @.4=7; @.5=11; @.6=13; #= 5; tp= 2; s= @.# + 2
do j=s by 2 while j<y
parse var j '' -1 _ /*obtain the last digit of the J var.*/
if _ ==5 then iterate /*is this integer a multiple of five? */
Line 622:
end /*k*/ /* [↑] only divide up to √ J */
#= #+1 /*bump the count of number of primes. */
@.#= j; _= # - 1
if j-2\==@._ then iterate /*This & previous prime not twins? Skip*/
end /*j*/
return tp</lang>
|