diff --git a/Screenshot from 2019-06-15 20-16-14.png b/Screenshot from 2019-06-15 20-16-14.png new file mode 100644 index 0000000..30e595e Binary files /dev/null and b/Screenshot from 2019-06-15 20-16-14.png differ diff --git a/eea.py b/eea.py new file mode 100644 index 0000000..535d356 --- /dev/null +++ b/eea.py @@ -0,0 +1,22 @@ +import sys +import math +#Python script for Extended Euclidean Algorithm +def egcd(a, b): + if a == 0: + return (b, 0, 1) + else: + gcd, x, y = egcd(b % a, a) + return (gcd, y - math.floor(b/a) * x, x) + +def main(): + if(len(sys.argv)!=3): + print("Usage: python3 eea.py a m") + print("\tax+by=1\n\tgdc(a,m)=1") + else: + a=int(sys.argv[1]) + m=int(sys.argv[2]) + gcd, x, y = egcd(a,m) + print("gdc:"+str(gcd)+" x:"+str(x)+" y:"+str(y)) + +if __name__ == "__main__": + main() diff --git a/extended-euclidean-algorithm.py b/extended-euclidean-algorithm.py deleted file mode 100644 index b04de47..0000000 --- a/extended-euclidean-algorithm.py +++ /dev/null @@ -1,27 +0,0 @@ -def mmi(a,power,m): - m0 = m - x0 = 0 - x1 = 1 - if m == 0: - return 0 - while a > 1: - # quotient - q = a/m - t = m - # euclids theorem - m= a%m - a = t - # back subs - t = x0 - x0 = x1-(q*x0) - x1 = t - if x1 < 0: - x1 += m0 - return x1 - -def main(): - base, power, mod = map(int, raw_input().strip().split(' ')) - print mmi(base, power, mod) - -if __name__ == "__main__": - main() \ No newline at end of file