mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-05 01:09:40 +08:00
Set the Python file maximum line length to 88 characters (#2122)
* flake8 --max-line-length=88 * fixup! Format Python code with psf/black push Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
# Diophantine Equation : Given integers a,b,c ( at least one of a and b != 0), the diophantine equation
|
||||
# a*x + b*y = c has a solution (where x and y are integers) iff gcd(a,b) divides c.
|
||||
# Diophantine Equation : Given integers a,b,c ( at least one of a and b != 0), the
|
||||
# diophantine equation a*x + b*y = c has a solution (where x and y are integers)
|
||||
# iff gcd(a,b) divides c.
|
||||
|
||||
# GCD ( Greatest Common Divisor ) or HCF ( Highest Common Factor )
|
||||
|
||||
@ -29,8 +30,9 @@ def diophantine(a, b, c):
|
||||
|
||||
# Finding All solutions of Diophantine Equations:
|
||||
|
||||
# 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.
|
||||
# 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.
|
||||
# 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. 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.
|
||||
|
||||
# n is the number of solution you want, n = 2 by default
|
||||
|
||||
@ -75,8 +77,9 @@ def greatest_common_divisor(a, b):
|
||||
>>> greatest_common_divisor(7,5)
|
||||
1
|
||||
|
||||
Note : In number theory, two integers a and b are said to be relatively prime, mutually prime, or co-prime
|
||||
if the only positive integer (factor) that divides both of them is 1 i.e., gcd(a,b) = 1.
|
||||
Note : In number theory, two integers a and b are said to be relatively prime,
|
||||
mutually prime, or co-prime if the only positive integer (factor) that
|
||||
divides both of them is 1 i.e., gcd(a,b) = 1.
|
||||
|
||||
>>> greatest_common_divisor(121, 11)
|
||||
11
|
||||
@ -91,7 +94,8 @@ def greatest_common_divisor(a, b):
|
||||
return b
|
||||
|
||||
|
||||
# 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)
|
||||
# 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)
|
||||
|
||||
|
||||
def extended_gcd(a, b):
|
||||
|
Reference in New Issue
Block a user