Skip to content

Instantly share code, notes, and snippets.

Francis, Lee Francis-Lee-Earth

  • Earth
Block or report user

Report or block Francis-Lee-Earth

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View ModularMultiplicativeInverse.py
def greatest_common_divisor_extended(a, b):
'''
擴展歐幾里得算法 (Extended Euclidean algorithm)
'''
if b == 0:
return a, 1, 0
gcd, y, x = greatest_common_divisor_extended(b, a % b)
return gcd, x, y - (a // b) * x
@Francis-Lee-Earth
Francis-Lee-Earth / GreatestCommonDivisor.py
Last active Oct 11, 2018
Greatest Common Divisor (GCD)
View GreatestCommonDivisor.py
def greatest_common_divisor(a, b):
"""
除非 b == 0,否則結果將與 b 具有相同的正負號
(因此,當 b 除以它,結果是正號)
"""
while b > 0:
a, b = b, a % b
return a
View MatrixInverse.py
import numpy as np
a = np.array([
[1, -2, -1],
[2, -1, 1],
[3, -6, -5]
])
a_inv = np.linalg.inv(a)
print("A:")
View Matrix.py
import numpy as np
a = np.array([
[5, 12],
[15, 25]
])
b = np.array(
[20, 10]
)
You can’t perform that action at this time.