diff --git a/algo.py b/algo.py
index 409838756317dd574dac54e8856c8d463ac1ba47..ae2f72245045583d11c94a3586f3c9e3767d8034 100644
--- a/algo.py
+++ b/algo.py
@@ -78,7 +78,7 @@ def exponentiation_rapide(a, exp, n):
     return int(r)
 
 
-def is_square(a):
+def is_perfect_square(a):
     """Check if a number is a perfect square, based on the "Babylonian algorithm" (Héron's method) for square root,
     from : https://stackoverflow.com/questions/2489435/check-if-a-number-is-a-perfect-square 
         
@@ -121,7 +121,7 @@ def fermat_factorization(n):
     a = math.ceil(math.sqrt(n)) # a = 26262277040 (for the key given)
     b2 = a**2 - n
     
-    while (not is_square(b2)): 
+    while ((a + int(math.sqrt(b2))) * (a - int(math.sqrt(b2))) != n): # (not is_perfect_square(b2)):
         a += 1
         b2 = a**2 - n