Skip to content

Commit

Permalink
cleaned up a littled and tried for smaller factors of F11
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyteitelbaum committed May 22, 2018
1 parent 6006ec7 commit 2baf0c8
Showing 1 changed file with 45 additions and 32 deletions.
77 changes: 45 additions & 32 deletions ctnt2018/ECM.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,43 +11,56 @@ def ecm(N,arange=100,krange=10000):
for a in range(-arange,arange):
x,y=0,1
for B in Primes10000:
k=B**(int(log(10000)/log(B)))
sx,sy,t=x,y,k
first=True
while t>0:
if t%2==1:
if first:
xm,ym=sx,sy
first=False
else:
d,u,v=gmpy2.gcdext(sx-xm,N)
if d>1:
if d==N:
break
else:
return d
L=(u*(sy-ym)) % N
x_sum=(L*L-xm-sx) % N
ym=(L*(xm-x_sum)-ym) % N
xm=x_sum
d,u,v=gmpy2.gcdext(2*sy,N)
if d>1:
if d==N:
k=10000
while k>0:
k=k//B
sx,sy,t=x,y,B
first=True
while True:
if t%2==1:
if first:
xm,ym=sx,sy
first=False
else:
d,u,v=gmpy2.gcdext(sx-xm,N)
if d>1:
if d==N:
break
else:
return d
L=(u*(sy-ym)) % N
x_sum=(L*L-xm-sx) % N
ym=(L*(xm-x_sum)-ym) % N
xm=x_sum
t=t//2
if t==0:
break
else:
return d
L=(u*(3*sx*sx+a)) % N
x2=(L*L-2*sx) % N
sy=(L*(sx-x2)-sy) %N
sx=x2
t=t//2
x,y=xm,ym
d,u,v=gmpy2.gcdext(2*sy,N)
if d>1:
if d==N:
break
else:
return d
L=(u*(3*sx*sx+a)) % N
x2=(L*L-2*sx) % N
sy=(L*(sx-x2)-sy) %N
sx=x2
x,y=xm,ym
print('Failed')


# First factored in 1980 by Brent and Pollard using rho method
# Factorization of the Eighth Fermat Number
# Richard Brent, John Pollard
# Mathematics of Computation, Volume 36, Number 154, April 1981
#V=1238926361552897
N=2**(256)+1
print('Factor of F8', ecm(N,arange=100,krange=10000),flush=True)

N=2**(128)+1
print('answer is', ecm(N,arange=100,krange=10000),flush=True)
# These smaller factors were found in 1988 by Brent

N=2**(2**11)+1
print('Factor of F11', ecm(N,arange=100,krange=10000),flush=True)



Expand Down

0 comments on commit 2baf0c8

Please sign in to comment.