20th October 2022- Python Lab
def getFactors(num:int)->list[int]:
'''Will return the list of factors of any number'''
return [i for i in range(1,num+1) if num%i==0]
# Python Lab, Date: 20th October 2022
def greatest_common_divisor(num1:int,num2:int)->int:
''''''
ls1=getFactors(num1)
ls2=getFactors(num2)
max=0
for elem in ls1:
if elem>max and elem in ls2:
max=elem
return max
print(greatest_common_divisor(4,8))
print(getFactors(8))
Comments
Post a Comment