trigo2.py

Created by maeldepallens

Created on January 29, 2022

1.29 KB


def pgcd(a,b):
  while b:
    a, b = b, a%b
  return a

def trigo2() :
    t = 1
    num = int(input("Numérateur : "))
    den = int(input("Dénominateur : "))
    a = num
    if a < 0 :
        a = -a
    if a < den :
        print("C'est la valeur Principale")
    else :
        for i in range(a) :
            if i%(den*2) == 0 :
                t = i
        if num < 0 :
            t = -t
        x = num - t
        u = t / (den* 2)
        if den < x < (2*den) and x > 0 :
            x = x - (2*den)
            if u <0 :
                u -= 1
            else :
                u += 1
        elif -den > x > -(2*den) and x < 0 :
            x = x + (2*den)
            if u <0 :
                u -= 1
            else :
                u += 1

        if den%x == 0 :
            den = den/x
            x = 1
        if x%den == 0 :
            x = x/den
            den = 1
        if pgcd(x,den)  != 1 :
            h =  pgcd(x,den)
            x = x/h
            den = den/h

    if x > 0 :
        if den == 1 :
            print(str(u)+"*2π + "+str(x)+"π")


        else :
            print(str(u)+"*2π + "+str(x)+"π/"+str(den))
    else :
        if den == 1 :
            print(str(u)+"*2π - "+str(-x)+"π")


        else :
            print(str(u)+"*2π - "+str(-x)+"π/"+str(den))



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.