Enhanced lcm: Least Common Multiple of N-Arguments of N Elements

Provides the least common multiple for an arbitrary number of variable-size arguments.
81 Downloads
Updated 23 Feb 2016

View License

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
Created with R2012a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Elementary Math in Help Center and MATLAB Answers
Tags Add Tags
lcm

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.0.0.0

Better title