Python/Maths/find_lcm.py
Michael Fried c92b02cfa3 Editing base64, Adding average file, Editing find_lcm (#673)
* avrage.py

calculate and print the avrage of number list.

* Update base64_cipher.py

encoding and decoding base64 without any module.

* Update and rename avrage.py to average.py

* update find_lcm algorithm

I made find_lcm more efficient form O(num1*num2) to O(min{num1,num2}).
2019-01-20 02:19:06 +05:30

19 lines
330 B
Python

def find_lcm(num_1, num_2):
max = num_1 if num_1 > num_2 else num_2
lcm = max
while (True):
if ((lcm % num_1 == 0) and (lcm % num_2 == 0)):
break
lcm += max
return lcm
def main():
num_1 = 12
num_2 = 76
print(find_lcm(num_1, num_2))
if __name__ == '__main__':
main()