N-argument least common multiple calculator with arbitrary precision

This function returns the least common multiple of the set of integers passed to it.

Sie verfolgen jetzt diese Einreichung

This function returns the least common multiple of the set of integers passed to it. The number of inputs can be very large. The function outputs the exact lcm integer. For instance, lcm(1,2,...,1000) is approximately 7.12e432 and vlcm will give all 433 digits. This function is an improvement over the function referenced below in that it uses the "vpa" routine built into MATLAB in order to give arbitrary precision.
usage: output = vlcm(M);
Here, M is the vector of integers for which the lcm is to be calculated.
In the first example we will calculate lcm(1,2,...,100):
>>vlcm(1:100)
ans =
69720375229712477164533808935312303556800
To get the number to 10 significant digits in scientific notation use vpa:
>> vpa(ans,10)
ans =
6.972037523e40
For another example we will calculate lcm(1,2,...,10000). This is impossible using the function referenced below. The number has 4349 digits so we will use scientific notation for brevity. We have:
>> vpa(vlcm(1:10000),10)
ans =
5.79333967e4348

The image is of the second Chebyshev function, which is given by log10(lcm(1,...,n)) and was calculated using this function

Zitieren als

Shawn Divitt (2026). N-argument least common multiple calculator with arbitrary precision (https://de.mathworks.com/matlabcentral/fileexchange/48312-n-argument-least-common-multiple-calculator-with-arbitrary-precision), MATLAB Central File Exchange. Abgerufen .

Allgemeine Informationen

Kompatibilität der MATLAB-Version

  • Kompatibel mit allen Versionen

Plattform-Kompatibilität

  • Windows
  • macOS
  • Linux
Version Veröffentlicht Versionshinweise Action
1.5.0.0

Fixed the title.

1.4.0.0

Added a better and more descriptive image.

1.3.0.0

Replaced the uint8 with uint32 in order to increase the number of allowable digits in the answer.

1.2.0.0

fixed an issue with small integers

1.1.0.0

added the requirement of the symbolic toolbox

1.0.0.0