Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
19
Task/Least-common-multiple/Python/least-common-multiple-4.py
Normal file
19
Task/Least-common-multiple/Python/least-common-multiple-4.py
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
>>> def lcm(*values):
|
||||
values = set([abs(int(v)) for v in values])
|
||||
if values and 0 not in values:
|
||||
n = n0 = max(values)
|
||||
values.remove(n)
|
||||
while any( n % m for m in values ):
|
||||
n += n0
|
||||
return n
|
||||
return 0
|
||||
|
||||
>>> lcm(-6, 14)
|
||||
42
|
||||
>>> lcm(2, 0)
|
||||
0
|
||||
>>> lcm(12, 18)
|
||||
36
|
||||
>>> lcm(12, 18, 22)
|
||||
396
|
||||
>>>
|
||||
Loading…
Add table
Add a link
Reference in a new issue