Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Sieve of Eratosthenes solution in Clear category for Restricted Prime by Tinus_Trotyl
def val(ch) : # numeric value generator
return "NABCDEFGHIX".index(ch)
def rng(a, b, c) : # replacement for R*A*N*G*E
y = []
while a < b :
y, a = y + [a], a + c
return y
def checkio(number): # sieve method
A, B, X = val("A"), val("B"), val("X") # number constants
primes, n, x = rng(A, X*X*X*X, A), B, B
while n < X*X : # start sieving
for m in rng(n+n, X*X*X*X, n) :
if m in primes : primes.remove(m)
x += A
n = primes[x]
return number in primes
May 13, 2017
Comments: