19 lines
366 B
Python
19 lines
366 B
Python
#rozszerzony algorytm euklidesa - rekurencyjny
|
|
|
|
x = 1
|
|
y = 0
|
|
def eulkides(a, b):
|
|
global x
|
|
global y
|
|
if (b != 0):
|
|
eulkides(b, a % b)
|
|
pom = y
|
|
y = int(x - a // b * y)
|
|
print("y = {} - {} / {} * {}, x = {}".format(x, a, b, pom, pom))
|
|
x = int(pom)
|
|
|
|
|
|
eulkides(5, 4)
|
|
print("4 * {} + 5 * {}".format(x, y))
|
|
|