arithmetique.py

Created by alexandrebret-84

Created on March 07, 2022

962 Bytes

pgcd


def pgcd(a, b):
    for i in str(a):
        if i == ".":
            return None
    for i in str(b):
        if i == ".":
            return None
    if a == 0 and b == 0:
        return "plus l'infini"
    elif b == 0:
        return abs(a) 
    elif a == 0:
        return abs(b)
    elif a < b:
        a, b = b, a
    while a % b != 0:
        c = a
        a = b
        b = c % b
    return abs(b)

def exo_33():
    for x in range(1, 277):
        for y in range(1, 277):
            if pgcd(x, y) == 1 and x * y == 276:
                print(23*x, y)
                print(x, 23*y)

def exo_34_1():
    for m in range(1, 361):
        for n in range(1, 361):
            if pgcd(m, n) == 1 and m * n == 360:
                print(m, 15*n)
                print(15*m, n)

def exo_34_2():
    for m in range(1, 1621):
        for n in range(1, 1621):
            if m**2 - n**2 == 1620 and pgcd(m, n) == 6:
                print(m, n)

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 cookies policy.