diff --git a/algo.py b/algo.py index 67f728b086d776dde4d78bb82c56c2a6fa88a290..409838756317dd574dac54e8856c8d463ac1ba47 100644 --- a/algo.py +++ b/algo.py @@ -79,7 +79,7 @@ def exponentiation_rapide(a, exp, n): def is_square(a): - """Check if a number is a perfect square, based on the "Babylonian algorithm" for square root, + """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 Args: @@ -93,7 +93,7 @@ def is_square(a): seen = set([x]) while x * x != a: - x = (x + (a // x)) // 2 + x = (x + (a // x)) // 2 # arithmetic average if x in seen: return False @@ -131,6 +131,7 @@ def fermat_factorization(n): b = int(math.sqrt(b2)) return (a, b) + def decode_msg(M): """Decode a code UTF-8 in characters from : Niklaus Eggenberg