mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-24 13:31:07 +00:00
a2236cfb97
* Improved Formatting of basic_maths.py - Added docstrings. - Improved whitespace formatting. - Renamed functions to match snake_case. * Improved Formatting of factorial_python.py - Added docstrings. - Improved whitespace formatting. - Renamed constants to match UPPER_CASE. * Improved Formatting of factorial_recursive.py - Improved whitespace formatting to meet PyLint standards. * Improved Code to Conform to PyLint - Renamed `max` to `max_num` to avoid redefining built-in 'max' [pylint] - Removed unnecessary parens after 'while' keyword [pylint] * Improved Formatting of factorial_recursive.py - Added docstrings. - Improved whitespace formatting.
26 lines
528 B
Python
26 lines
528 B
Python
"""Find Least Common Multiple."""
|
|
|
|
# https://en.wikipedia.org/wiki/Least_common_multiple
|
|
|
|
|
|
def find_lcm(num_1, num_2):
|
|
"""Find the LCM of two numbers."""
|
|
max_num = num_1 if num_1 > num_2 else num_2
|
|
lcm = max_num
|
|
while True:
|
|
if ((lcm % num_1 == 0) and (lcm % num_2 == 0)):
|
|
break
|
|
lcm += max_num
|
|
return lcm
|
|
|
|
|
|
def main():
|
|
"""Use test numbers to run the find_lcm algorithm."""
|
|
num_1 = 12
|
|
num_2 = 76
|
|
print(find_lcm(num_1, num_2))
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|