euclide.py

Created by christian-mercat

Created on December 12, 2023

625 Bytes

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()

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our <a href="https://www.numworks.com/legal/cookies-policy/">cookies policy</a>.