Anti-primes: Difference between revisions
Content added Content deleted
m (→even and odd numbers: simplified the code.) |
|||
Line 1,314: | Line 1,314: | ||
#= # + 1; maxD= d /*found an anti─prime #; set new minD.*/ |
#= # + 1; maxD= d /*found an anti─prime #; set new minD.*/ |
||
say center(#, 7) right(j, 10) /*display the index and the anti─prime.*/ |
say center(#, 7) right(j, 10) /*display the index and the anti─prime.*/ |
||
if #>=N then leave |
if #>=N then leave /*if we have enough anti─primes, done. */ |
||
end /*j*/ |
end /*j*/ |
||
end /*once*/ |
end /*once*/ |
||
Line 1,321: | Line 1,321: | ||
#divs: procedure; parse arg x 1 y /*X and Y: both set from 1st argument.*/ |
#divs: procedure; parse arg x 1 y /*X and Y: both set from 1st argument.*/ |
||
if x<3 then return x /*handle special cases for one and two.*/ |
if x<3 then return x /*handle special cases for one and two.*/ |
||
if x==4 then return 3 /* " " " |
if x==4 then return 3 /* " " " " four. */ |
||
if x<6 then return 2 /* " " " |
if x<6 then return 2 /* " " " " three or five*/ |
||
odd= x // 2 /*check if X is odd or not. */ |
odd= x // 2 /*check if X is odd or not. */ |
||
if odd then |
if odd then #= 1 /*Odd? Assume Pdivisors count of 1.*/ |
||
else do; #= 3; y= x%2; end /*Even? " " " " 3.*/ |
else do; #= 3; y= x%2; end /*Even? " " " " 3.*/ |
||
/* [↑] start with known num of Pdivs.*/ |
/* [↑] start with known num of Pdivs.*/ |