Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Some cheating, O(sqrt(n)) solution in Creative category for Restricted Prime by nickie
def checkio(number):
# useful numbers
zero = number^number
one = number**zero
two = one+one
three = two+one
minus_one = ~one+one
# and operations
sb = lambda x, y: x + y * minus_one
dv = lambda x, y: int(x * y ** minus_one)
md = lambda x, y: sb(x, y * dv(x, y))
# let's play ball now...
if number < two: return False # less than two is not a prime
if number == two: return True # two is a prime
if number & one == zero: return False # even numbers are not prime
t = three
while t*t <= number:
if md(number, t) == zero: return False
t += two
return True
Dec. 31, 2013