View source code
Display the source code in std/numeric.d from which thispage was generated on github.
Report a bug
If you spot a problem with this page, click here to create aBugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.Requires a signed-in GitHub account. This works well for small changes.If you'd like to make larger changes you may want to consider usinglocal clone.
Function std.numeric.lcm
Computes the least common multiple of a
and b
.
Arguments are the same as gcd
.
typeof(Unqual!T .init%Unqual!U .init) lcm(T, U)(
T a,
U b
)
if (isIntegral!T && isIntegral!U);
auto lcm(T)(
T a,
T b
)
if (!isIntegral!T && is(typeof(T .init % T .init)) && is(typeof(T .init == 0 || T .init > 0)));
Returns
The least common multiple of the given arguments.
Example
writeln(lcm(1, 2)); // 2
writeln(lcm(3, 4)); // 12
writeln(lcm(5, 6)); // 30
Authors
Andrei Alexandrescu, Don Clugston, Robert Jacques, Ilya Yaroshenko
License
Copyright © 1999-2025 by the D Language Foundation | Page generated by ddox.