Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
18
Task/Least-common-multiple/Python/least-common-multiple-5.py
Normal file
18
Task/Least-common-multiple/Python/least-common-multiple-5.py
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
>>> def lcm(p,q):
|
||||
p, q = abs(p), abs(q)
|
||||
m = p * q
|
||||
if not m: return 0
|
||||
while True:
|
||||
p %= q
|
||||
if not p: return m // q
|
||||
q %= p
|
||||
if not q: return m // p
|
||||
|
||||
|
||||
>>> lcm(-6, 14)
|
||||
42
|
||||
>>> lcm(12, 18)
|
||||
36
|
||||
>>> lcm(2, 0)
|
||||
0
|
||||
>>>
|
||||
Loading…
Add table
Add a link
Reference in a new issue