Skip to content
Snippets Groups Projects
Commit a23a3c55 authored by adrian.spycher's avatar adrian.spycher
Browse files

fermat_factorization handle false n

parent 2cf1bef8
No related branches found
No related tags found
No related merge requests found
...@@ -110,8 +110,9 @@ def fermat_factorization(n): ...@@ -110,8 +110,9 @@ def fermat_factorization(n):
""" """
a = math.ceil(math.sqrt(n)) a = math.ceil(math.sqrt(n))
# a = 26262277040 - 10
b = 0 b = 0
while(True): while(a <= n): # a cannot be greater than n, because : n = (a + b) * q > 0 => a <= n
b2 = a**2 - n b2 = a**2 - n
if (is_square(b2)): if (is_square(b2)):
...@@ -120,6 +121,8 @@ def fermat_factorization(n): ...@@ -120,6 +121,8 @@ def fermat_factorization(n):
a += 1 a += 1
if(a > n): print("The Fermat's factorization didn't work on n")
return (a, b) return (a, b)
def decode_msg(M): def decode_msg(M):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment