Division euclidienne graphique
from matplotlib.pyplot import * def pgcd(a, b): if b == 0: return a else: plot((0,a,a,0),(0,0,b,b)) if a>b: return pgcd(a-b, b) return pgcd(a, b-a) def orthon(xmin, xmax, ymin, ymax): L_ECRAN, H_ECRAN = 320, 222 if xmin is None: xmin = xmax - (ymax - ymin) * L_ECRAN / H_ECRAN elif xmax is None: xmax = (ymax - ymin) * L_ECRAN / H_ECRAN + xmin elif ymin is None: ymin = ymax - (xmax - xmin) * H_ECRAN / L_ECRAN else: ymax = (xmax - xmin) * H_ECRAN / L_ECRAN + ymin return (xmin, xmax, ymin, ymax) print(pgcd(241,100)) axis(orthon(-1,240,-1,None)) show()