GCD

    0

    0

    Mahendra Kumar

    mathsbeginner

    Calculating the GCD of Two Numbers

    # take inputs
    x = int(input('Enter First Number: '))
    y = int(input('Enter Second Number: '))
    # choose the smaller number
    if x > y:
        smaller = y
    else:
        smaller = x
    # find gcd of the number
    for i in range (1,smaller+1):
        if((x % i == 0) and (y % i == 0)):
            gcd = i
    # display result
    print('The GCD of',x,'and',y,'is',gcd)
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    Legal
    • Security
    • Privacy Policy
    • Code Privacy
    • Terms of Service
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.