Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Determining the Least Common Multiple.

Determining the Least Common Multiple

Written by Allen Wyatt (last updated July 1, 2022)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365


5

Remember your junior-high math classes? The teacher would write three or four numbers on the chalkboard and ask you to determine what larger number each of the numbers on the board could be a factor of. For instance, if the numbers were 2, 3,and 4, then they are all factors of the number 12. Thus, 12 is the least common multiple of those three numbers.

Things got really difficult when the teacher threw up six, seven, or ten numbers. Yikes! Fortunately, Excel makes calculating the least common multiple rather easy. All you need to do is put the numbers in a range of cells, and then use a formula like this:

=LCM(C20:C23)

In just a jiffy Excel returns a value that, sure enough, would have made that math teacher proud.

Just one gotcha here: If you use non-integer values with the LCM function, everything past the decimal point is ignored. In other words, the values are truncated before LCM does its magic. So, the bottom line is to make sure you are working with actual integers with LCM.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (5833) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. You can find a version of this tip for the older menu interface of Excel here: Determining the Least Common Multiple.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Jumping to a Range

Need a quick way to jump to a particular part of your worksheet? You can do it by using the Go To dialog box.

Discover More

Adjusting Table Row Height

When working with tables, you can adjust the height of individual rows. How you go about such adjustments depends on the ...

Discover More

Sharing Headings with Others

Headings form the outline of your document and hopefully give it an easy-to-follow organization. If you want to share ...

Discover More

Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2013 For Dummies today!

More ExcelTips (ribbon)

Modifying Proper Capitalization

The PROPER worksheet function is used to change the case of text so that the first letter of each word is capitalized. If ...

Discover More

Specifying a Date Range in a SUMIFS Formula

The SUMIFS function allows you to specify criteria by which values can be included in a sum. Putting together the ...

Discover More

Calculating the Day of the Year

Need to know what day of the year a certain date is? You can figure it out easily using the formulas in this tip.

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 8 - 2?

2022-07-03 11:59:28

Ronmio

One way "to make sure you are working with actual integers with LCM" if you do have decimal numbers, is to convert the them to integers first. Let's say your numbers go to two decimal places. The formula to get their LCM would be:

=LCM(C20:C23*100)/100

If yours numbers go to three decimal places, then the 100's would need to be changed to 1000's, and so on. A more generic version (for up to 6 decimal places) might be:

=LCM(C20:C23*1000000)/1000000


2020-03-26 10:26:32

Peter Atherton

Hmm, It is a pity that there is now editing function here. Someone else has also made this comment ealier.

The first Pic is

(see Figure 1 below)

Figure 1. 


2020-03-26 10:21:09

Peter Atherton

For something to do while stuck in the house I thought I'd try remembering how the HCF and HCD (GCD) worked.
The HFC is got by muliplying all the values and dividing the answer by the smallest value. A couple of functions are available, the PRODUCT and MIN functions. I also put these functions into a UDF as follows:

Function myLCM(ByVal ref)
Dim myMin As Long, myProd As Long
myProd = Evaluate("product(" & ref.Address & ")")
myMin = Evaluate("Min(" & ref.Address & ")")
myLCM = myProd / myMin
End Function

(see Figure 1 below)
The HCD (GCD) requires two loops, not shown in pic2. an outer loop For i = 1 to ref.count and an inner loop, Do ....Until a = 0. Here it is:

Function myHCD(ByVal ref)
Dim i As Long
Dim a, b, c

For i = 1 To ref.Count - 1
If IsEmpty(ref(i)) Then
i = i + 1
End If
If ref(i) > ref(i + 1) Then
a = ref(i): b = ref(i + 1)
Else: a = ref(i + 1): b = ref(i)
End If

Do
c = a Mod b
a = b
b = c
Loop Until b = 0

Next i
myHCD = a
End Function

(see Figure 2 below)

Figure 1. HCF Formula & UDF

Figure 2. HCD (GCD)


2020-03-24 11:19:13

Peter Atherton

John,
The HCF is called GCD (Greatest Common Denominator). Separated by a common language?


2020-03-23 17:06:30

John Mann

I Just noticed this tip. It took me back a very long way to my school days (I'm now 78), I don't remember the procedure any more, but I do remember that was one of the topics.

Along with LCM calculations, we were also taught the procedure for HCF calculations (Highest Common Multiple). So I immediately went and looked for that function in Excel 2010 - no joy.

As a matter of interest, got the same result for Open Office 4.14 - the LCM function worked, but no HCF function. I also tried the last version of Lotus 1-2-3. Neither function appeared to exist, but I couldn't check the help files since they won't run in Windows 10


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.