Revision history [back]

Here is a more or less direct translation:

def f(n,p):
d = ceil(log(2)/log(10)*(n-1))
s = GF(p)(2)^(n-1)
t = s.lift()^d
u = GF(p)((2*s-1)*t + s - 1).lift()
return u

v = set(srange(100000,101000+1))

for q in primes(10^7):
z = next((m for m in v if f(m,q) == 0), None)
if z is not None:
v -= set([z])
print q, ' ', len(str(z)), ' ', len(v)

It seems unnecessary (in Sage, at least) to lift s in the definition of t. More efficient would be:

t = s^d
u = ((2*s-1)*t + s - 1).lift()

Here is a more or less direct translation:

def f(n,p):
d = ceil(log(2)/log(10)*(n-1))
s = GF(p)(2)^(n-1)
t = s.lift()^d
u = GF(p)((2*s-1)*t + s - 1).lift()
return u

v = set(srange(100000,101000+1))

for q in primes(10^7):
z = next((m [m for m in v if f(m,q) == 0), None)
0]
if z is not None:
len(z) > 0:
v -= set([z])
set(z)
print q, ' ', len(str(z)), len(z), ' ', len(v)

It seems unnecessary (in Sage, at least) to lift s in the definition of t. More efficient would be:

t = s^d
u = ((2*s-1)*t + s - 1).lift()

Here is a more or less direct translation:

def f(n,p):
d = ceil(log(2)/log(10)*(n-1))
s = GF(p)(2)^(n-1)
t = s.lift()^d
GF(p)(10)^d
u = GF(p)((2*s-1)*t ((2*s-1)*t + s - 1).lift()
return u

v = set(srange(100000,101000+1))

for q in primes(10^7):
z = [m for m in v if f(m,q) == 0]
if len(z) > 0:
v -= set(z)
print q, ' ', len(z), ' ', len(v)

It seems unnecessary (in Sage, at least) to lift s in the definition of t. More efficient would be:

t = s^d
u = ((2*s-1)*t + s - 1).lift()

Here is a more or less direct translation:

def f(n,p):
d = ceil(log(2)/log(10)*(n-1))
s = GF(p)(2)^(n-1)
t = GF(p)(10)^d
u = ((2*s-1)*t + s - 1).lift()
return u

v = set(srange(100000,101000+1))

for q in primes(10^7):
z = [m for m in v if f(m,q) == 0]
if len(z) > 0:
v -= set(z)
print q, ' ', len(z), ' ', len(v)