Finding GCD of all numbers between given two numbers.
def GCD(a,b):
if a==0:
return b
elif b==0:
return a
else:
return GCD(b,a%b)
def GCDN(k,l):
t = k
for i in range(k+1,l):
t = GCD(t,i)
return t
a = int(input("Enter First Range of Element : "))
b = int(input("Enter Last Range of Element : "))
print("GCD of all numbers between ", a ," and ", b ," is :",
GCDN(a,b))
No comments:
Post a Comment
let me know which type examples you want to comment me.