Smallest multiple: Difference between revisions
Content deleted Content added
Line 465: | Line 465: | ||
for 10, it's 2520 |
for 10, it's 2520 |
||
for 20, it's 232792560 |
for 20, it's 232792560 |
||
</pre> |
|||
=={{header|Python}}== |
|||
<lang python>""" Rosetta code task: Smallest_multiple """ |
|||
from math import gcd |
|||
from functools import reduce |
|||
def lcm(a,b): |
|||
""" least common multiple """ |
|||
return int(abs(a*b) / gcd(a,b)) |
|||
for i in [10, 20, 200]: |
|||
print(i, ": ", reduce(lcm, list(range(1, i+1)))) |
|||
</lang>{{out}} |
|||
<pre> |
|||
10 : 2520 |
|||
20 : 232792560 |
|||
200 : 406223405488266528941807089475561526729920491439317610846106007364194068990773980214853993805940114288328203598436687354558152299530325929626578124378588043546734967334192274905429717169202850358367337285700993918963748498703256809194612087695134987729083306000942716524953600 |
|||
</pre> |
</pre> |
||