def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a

def cancel_frac(a, b):
    while True:
        g = gcd(a, b)
        if g == 1:
            break

        a //= g
        b //= g

    return a, b

def main():
    n, d = [int(x) for x in input().split('/')]
    n1, d1 = cancel_frac(n, d)
    print(f'{n1}/{d1} = {n1/d1}')

main()

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: