PGCD
Author: Daniel Mentrard
Date: 21 Septembre 2014

Calculons le PGCD de deux nombre entiers 
a et b (a>b) à l'aide de l'algorithme d'Euclide :

Choisir ces deux nombres ici:

Remarque: si le PGCD de deux nombres est égal à 1,
alors ces deux nombres sont premiers entre eux.

:

:

a = 120 (slider from 1 to 5000, step 1)
b = 45 (slider from 1 to 5000, step 1)
aa = Mod(a, b)
dd = Mod(b, aa)
ff = Mod(aa, dd)
hh = Mod(dd, ff)
jj = Mod(ff, hh)
ll = Mod(hh, jj)
nn = Mod(jj, ll)
pp = Mod(ll, nn)
rr = Mod(nn, pp)
tt = Mod(pp, rr)
vv = Mod(rr, tt)
pgd = If(vv ≟ 0, tt, If[tt ≟ 0, rr, If[rr ≟ 0, pp, If[pp ≟ 0, nn, If[nn ≟ 0, ll, If[ll ≟ 0, jj, If[jj ≟ 0, hh, If[hh ≟ 0, ff, If[ff ≟ 0, dd, aa]]]]]]]])
T1: "PGCD ( " + a + " ; " + b + " ) = ?"
d: b - (a - b)
c: a - b
T2: "+ " + aa
T3: "" + a + " = "
T4: "" + b
bb: (a - aa) / b
T8: "x " + bb
T5: "" + b + " = "
cc: (b - dd) / aa
T6: "x " + cc
T7: "" + aa
T9: "+ " + dd
T10: "" + aa + " = "
T11: "" + dd
ee: (aa - ff) / dd
T12: "x  " + ee
T13: "+ " + ff
T16: "" + dd + " = "
T17: "" + ff
gg: (dd - hh) / ff
T18: "x " + gg
T19: "+ " + hh
T20: "" + ff + " = "
T21: "" + hh
ii: (ff - jj) / hh
T22: "x " + ii
T23: "+ " + jj
T24: "" + hh + " ="
T25: " " + jj
kk: (hh - ll) / jj
T26: "x " + kk
T27: "+ " + ll
T28: "" + jj + " ="
T29: "" + ll
mm: round(jj / ll)
T30: "x  " + mm
T31: "+ " + nn
T32: "" + ll + " ="
T33: "" + nn
oo: (ll - pp) / nn
T34: "x " + oo
T35: "+ " + pp
T36: "" + nn + " ="
T37: "" + pp
T38: "+ " + rr
qq: (nn - rr) / pp
T39: " x " + qq
T40: "" + pp + " ="
T41: "" + rr
T42: "+ " + tt
ss: (pp - tt) / rr
T43: "x " + ss
T44: "" + rr + " ="
T45: "" + tt
T46: "+ " + vv
uu: (rr - vv) / tt
T47: "x " + uu
T14: "Il faut prendre le dernier reste avant le zéro, 
donc PGCD (" + a + " ; " + b + ") = " + pgd
A = (4, 4)
B = (4, -4)
e = Line(B, A)
C = (1.5199999999999998, 0.9800000000000001)
f = Circle(C, 0.5)
D = (1.5999999999999999, 5.120000000000001)
g = Circle(D, 0.5)
E = (1.5599999999999998, 4.079999999999998)
h = Circle(E, 0.5)
F = (1.5400000000000005, 3.04)
k = Circle(F, 0.5)
G = (1.5199999999999998, 2.04)
p = Circle(G, 0.5)
H = (1.46, -0.06000000000000005)
q = Circle(H, 0.5)
I = (1.46, -1.08)
r = Circle(I, 0.5)
J = (1.48, -2.12)
s = Circle(J, 0.5)
K = (1.46, -3.14)
t = Circle(K, 0.5)
L = (1.44, -4.14)
c1 = Circle(L, 0.5)
T48: "" + a
M = (5, 4)
N = (5, 2.54)
O = (8, 2.56)
P = (8, 4)
poly1, m, n, o, p_1 = Polygon(M, N, O, P)
Q = (11, 4)
R = (14, 4)
S = (14, 2.5)
T = (11.02, 2.5)
poly2, q_1, r_1, s_1, t_1 = Polygon(Q, R, S, T)
T52: "" + a + " et " + b + " sont premier entre eux."
ChampTexte1 = Textfield(a)
ChampTexte2 = Textfield(b)