// is_prime(n)
// A general primality test; an adaptation of code written by Yourself
if (argument0 < 4) return (argument0 > 1);
if !(argument0 mod 2 && argument0 mod 3) return false;
var a, m, d;
a[1] = 2; a[3] = 4; a[5] = 2; a[7] = 2; a[9] = 2;
m = sqrt(argument0);
for (d = 5; d < m; d += a[d mod 10])
if (argument0 mod d == 0)
return false;
return true;
Categories: Mathematics
There are no comments to display.
You must be signed in to post comments.