Skip to content
Snippets Groups Projects
Commit 41260c43 authored by gawen.ackerman's avatar gawen.ackerman :robot:
Browse files

réalisation bachet-bézout

parent 6d3b69a3
No related branches found
No related tags found
No related merge requests found
from numbers import Number
import itertools
import json
from typing import Tuple
def unicode_superscripts(value):
......@@ -86,6 +87,36 @@ class Polynomial:
return str_value
def compute_bachet_bezout(a, b):
r = []
x = []
y = []
q = []
# Init
r.append(a)
x.append(1)
y.append(0)
q.append(0)
r.append(b)
x.append(0)
y.append(1)
q.append(0)
# Computing
i = 1
while r[i] > 0:
i += 1
r.append(r[i-2] % r[i-1])
q.append(int(r[i-2] / r[i-1]))
if r[i] > 0:
x.append(x[i-2]-q[i]*x[i-1])
y.append(y[i-2]-q[i]*y[i-1])
return x[-1], y[-1]
def compute_lagrange_polynomial(points, prime_number):
pass
......@@ -99,11 +130,16 @@ def main():
p1 = Polynomial((5, 1, 4))
p2 = Polynomial((5, 2, 3, 4))
p3 = p1*p2
print(p1)
print(p2)
print(p3)
print(p3%4)
print(p3%5)
# print(p1)
# print(p2)
# print(p3)
# print(p3 % 4)
# print(p3 % 5)
a = 168
b = 68
x, y = compute_bachet_bezout(a, b)
print("Pour les chiffres " + str(a) + " et " + str(b) +
". Les coéfficients de Bachet-Bézout sont : " + str(x) + " et " + str(y))
with open("messages.json") as f:
messages = json.load(f)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment