Python program to find GCD or HCF using function

0
1094
def hcf(a, b):
    if a > b:   # choose the smaller number
        smaller = b
    else:
        smaller = a
    for i in range(1, smaller+1):
        if((a % i == 0) and (b % i == 0)):
            hcf = i 
    return hcf
#_____main_____
num1 = int(input("Please enter first number: "))
num2 = int(input("Please enter second number: "))
print("The H.C.F. is", hcf(num1, num2))

     Output 1:
             Please enter first number: 24
             Please enter second number: 28
             The H.C.F. is 4
     Output 2:
             Please enter first number: 60
             Please enter second number: 72
             The H.C.F. is 12

इन्हें भी देखें।

Python Programs के लिये यहाँ click करें।

 

 

 

Python program to find GCD or HCF using function program to find GCD or HCF using function in python Python program to find GCD Python program to find HCF Python program to find GCD or HCF write a program to find GCD or HCF using function write a python program to find GCD or HCF using function write a program to find GCD or HCF write a program to find GCD write a program to find HCF gcd program in python HCF program in python gcd program in python using function HCF program in python using function Python program GCD gcd python program using function gcd of two numbers python program

 

 

LEAVE A REPLY

Please enter your comment!
Please enter your name here