Anonymous user
Twin primes: Difference between revisions
m
→straight-forward prime generator: optimized the GENP function.
(Added Sidef) |
m (→straight-forward prime generator: optimized the GENP function.) |
||
Line 1,097:
commas: parse arg _; do ?=length(_)-3 to 1 by -3; _=insert(',', _, ?); end; return _
/*──────────────────────────────────────────────────────────────────────────────────────*/
genP: parse arg y;
do j=
parse var j '' -1 _
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 */
prev= @.#;
if j-2==prev then tp= tp + 1 /*This & previous prime twins? Bump TP.*/
end /*j*/; return tp</lang>
{{out|output|text= when using the default inputs:}}
<pre>
|