1- # Diophantine Equation : Given integers a,b,c ( at least one of a and b != 0), the diophantine equation
2- # a*x + b*y = c has a solution (where x and y are integers) iff gcd(a,b) divides c.
1+ # Diophantine Equation : Given integers a,b,c ( at least one of a and b != 0), the
2+ # diophantine equation a*x + b*y = c has a solution (where x and y are integers)
3+ # iff gcd(a,b) divides c.
34
45# GCD ( Greatest Common Divisor ) or HCF ( Highest Common Factor )
56
@@ -29,8 +30,9 @@ def diophantine(a, b, c):
2930
3031# Finding All solutions of Diophantine Equations:
3132
32- # Theorem : Let gcd(a,b) = d, a = d*p, b = d*q. If (x0,y0) is a solution of Diophantine Equation a*x + b*y = c.
33- # a*x0 + b*y0 = c, then all the solutions have the form a(x0 + t*q) + b(y0 - t*p) = c, where t is an arbitrary integer.
33+ # Theorem : Let gcd(a,b) = d, a = d*p, b = d*q. If (x0,y0) is a solution of Diophantine
34+ # Equation a*x + b*y = c. a*x0 + b*y0 = c, then all the solutions have the form
35+ # a(x0 + t*q) + b(y0 - t*p) = c, where t is an arbitrary integer.
3436
3537# n is the number of solution you want, n = 2 by default
3638
@@ -75,8 +77,9 @@ def greatest_common_divisor(a, b):
7577 >>> greatest_common_divisor(7,5)
7678 1
7779
78- Note : In number theory, two integers a and b are said to be relatively prime, mutually prime, or co-prime
79- if the only positive integer (factor) that divides both of them is 1 i.e., gcd(a,b) = 1.
80+ Note : In number theory, two integers a and b are said to be relatively prime,
81+ mutually prime, or co-prime if the only positive integer (factor) that
82+ divides both of them is 1 i.e., gcd(a,b) = 1.
8083
8184 >>> greatest_common_divisor(121, 11)
8285 11
@@ -91,7 +94,8 @@ def greatest_common_divisor(a, b):
9194 return b
9295
9396
94- # Extended Euclid's Algorithm : If d divides a and b and d = a*x + b*y for integers x and y, then d = gcd(a,b)
97+ # Extended Euclid's Algorithm : If d divides a and b and d = a*x + b*y for integers
98+ # x and y, then d = gcd(a,b)
9599
96100
97101def extended_gcd (a , b ):
0 commit comments