Enhanced lcm: Least Common Multiple of N-Arguments of N Elements
Overview:
Provides the least common multiple of an arbitrary number of arguments, each with an arbitrary number of elements. Also handles the case of a single input without throwing an error by returning that input as the lcm. Multidimensional inputs will find the least common multiple of all elements used, and the computation time can grow exponentially.
Method:
The least common multiple must be a multiple of all numbers, by definition. Using that, it is simple to step through all multiples of the last input, stopping when the current multiple is divisible by all the other inputs. For prime inputs, the least common mulitple is the product of all the inputs, so this is used as an upper bound on the least common multiple.
Cite As
David Guglielmo (2024). Enhanced lcm: Least Common Multiple of N-Arguments of N Elements (https://www.mathworks.com/matlabcentral/fileexchange/55618-enhanced-lcm-least-common-multiple-of-n-arguments-of-n-elements), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
- MATLAB > Mathematics > Elementary Math >
Tags
Acknowledgements
Inspired by: N-argument least common multiple calculator with arbitrary precision
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
Version | Published | Release Notes | |
---|---|---|---|
1.0.0.0 | Better title |