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,8 +1,9 @@
|
||||
# Chinese Remainder Theorem:
|
||||
# GCD ( Greatest Common Divisor ) or HCF ( Highest Common Factor )
|
||||
|
||||
# If GCD(a,b) = 1, then for any remainder ra modulo a and any remainder rb modulo b there exists integer n,
|
||||
# such that n = ra (mod a) and n = ra(mod b). If n1 and n2 are two such integers, then n1=n2(mod ab)
|
||||
# If GCD(a,b) = 1, then for any remainder ra modulo a and any remainder rb modulo b
|
||||
# there exists integer n, such that n = ra (mod a) and n = ra(mod b). If n1 and n2 are
|
||||
# two such integers, then n1=n2(mod ab)
|
||||
|
||||
# Algorithm :
|
||||
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
# GCD ( Greatest Common Divisor ) or HCF ( Highest Common Factor )
|
||||
|
||||
# Given three integers a, b, and n, such that gcd(a,n)=1 and n>1, the algorithm should return an integer x such that
|
||||
# 0≤x≤n−1, and b/a=x(modn) (that is, b=ax(modn)).
|
||||
# Given three integers a, b, and n, such that gcd(a,n)=1 and n>1, the algorithm should
|
||||
# return an integer x such that 0≤x≤n−1, and b/a=x(modn) (that is, b=ax(modn)).
|
||||
|
||||
# Theorem:
|
||||
# a has a multiplicative inverse modulo n iff gcd(a,n) = 1
|
||||
@@ -68,7 +68,8 @@ def modular_division2(a, b, n):
|
||||
return x
|
||||
|
||||
|
||||
# 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):
|
||||
@@ -123,8 +124,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
|
||||
|
||||
Reference in New Issue
Block a user