Discussion about math, puzzles, games and fun. Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ π -¹ ² ³ °

You are not logged in.

- Topics: Active | Unanswered

**MathsIsFun****Administrator**- Registered: 2005-01-21
- Posts: 7,559

I have updated this page: Least Common Multiple Calculator

Could you throw some numbers at it and let me know if it behaves itself, thank you.

"The physicists defer only to mathematicians, and the mathematicians defer only to God ..." - Leon M. Lederman

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 92,930

Hi MIF;

It is a nice little calculator. Very good!

**In mathematics, you don't understand things. You just get used to them.**

**I agree with you regarding the satisfaction and importance of actually computing some numbers. I can't tell you how often I see time and money wasted because someone didn't bother to run the numbers.**

**Online**

**John E. Franklin****Member**- Registered: 2005-08-29
- Posts: 3,585

Seems to work like a charm!! Did 2 and 3 numbers filled in, primes and related multiple cousins etc.

**igloo** **myrtilles** **fourmis**

Offline

**MathsIsFun****Administrator**- Registered: 2005-01-21
- Posts: 7,559

Thanks both.

Quality control

"The physicists defer only to mathematicians, and the mathematicians defer only to God ..." - Leon M. Lederman

Offline

**MathsIsFun****Administrator**- Registered: 2005-01-21
- Posts: 7,559

Thank You Beth!

"The physicists defer only to mathematicians, and the mathematicians defer only to God ..." - Leon M. Lederman

Offline

**MathsIsFun****Administrator**- Registered: 2005-01-21
- Posts: 7,559

New version (0.6): Least Common Multiple Calculator

I upgraded it to use my "Full Precision" functions, so it can handle larger numbers, so lots of changes to internal calcs.

Again, could you throw some numbers at it?

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 92,930

Hi;

It is working fine. No problems.

**In mathematics, you don't understand things. You just get used to them.**

**I agree with you regarding the satisfaction and importance of actually computing some numbers. I can't tell you how often I see time and money wasted because someone didn't bother to run the numbers.**

**Online**

**noelevans****Member**- Registered: 2012-07-20
- Posts: 236

Hi MIF!

Did you mean for it to work with decimals too? The few I tested worked.

Did you mean for it to work with negative numbers? That didn't work.

Works nice for positive integers.

You might consider limiting the inputs to just positive integers.

Zero poses a problem, since any number times zero equals zero. multiplies of zero are 0,0,0,...

The multiples of 2 are 0,2,4,6,... So accordingly lcm(0,2) would be zero.

People are going to try to input all kinds of numbers if there are no restrictions.

It may be better to simply not accept their inputs rather than accept the inputs and then

not get an answer or get an answer they can't understand.

Writing "pretty" math (two dimensional) is easier to read and grasp than LaTex (one dimensional).

LaTex is like painting on many strips of paper and then stacking them to see what picture they make.

Offline

**anonimnystefy****Real Member**- From: The Foundation
- Registered: 2011-05-23
- Posts: 15,891

lcm is defined for positive integers only, so why should anyone input anything else, besides their curiosity?

Here lies the reader who will never open this book. He is forever dead.

Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment

The knowledge of some things as a function of age is a delta function.

Offline

**MathsIsFun****Administrator**- Registered: 2005-01-21
- Posts: 7,559

I could reject the "-" sign.

Offline

**noelevans****Member**- Registered: 2012-07-20
- Posts: 236

Hi MIF!

You could allow the minus sign, since according to Wikipedia the lcm of two integers is the smallest

POSITIVE integer that is divisible by both. In essence the minus signs are just ignored. Wiki also

says that if either a or b is zero then the lcm is zero.

I've never seen lcm applied to decimals although your program seems to work accepting them as input but treats them as if they had no decimals and then outputs the correct integer accordingly but puts a decimal in the answer so that both inputs divide into it an INTEGRAL number of times.

If I input 2.43 and 8.1 into your program it outputs 24.3 which both 2.43 and 8.1 divide into an

INTEGRAL number of times. So maybe you've come up with a way to define lcms of terminating

decimals! Inputting .166 and .333 gives 55.278 which both .166 and .333 divide into an INTEGRAL

number of times. Perhaps this could be extended to fractions if we write them in a base that makes BOTH of them TERMINATING decimals???

Hmmmmmmmm...

Writing "pretty" math (two dimensional) is easier to read and grasp than LaTex (one dimensional).

LaTex is like painting on many strips of paper and then stacking them to see what picture they make.

Offline

**MathsIsFun****Administrator**- Registered: 2005-01-21
- Posts: 7,559

Thanks noelevans, well argued and well said.

Offline

**noelevans****Member**- Registered: 2012-07-20
- Posts: 236

Hi again!

Take the equation

x 3x

----- + ----- = 10 and multiply both sides by the lcm 24.3 that your program gives.

2.43 8.1

Then we get 10x + 9x = 243 so 19x=243 so x=12.789. So maybe there are some decent

applications for the concept.

Of course we could have multiplied the equation through by both 8 .1 and 2.43 and solved, but

then we would have had decimal coefficients for the variable.

8.1x + 3(2.43)x = 10(8.1*2.43)

8.1x + 7.29x = 196.83

15.39x = 196.83

x = 196.83/15.39

x = 12.789

Does make the arithmetic a bit easier!

But perhaps we can get lcms for fractions a/b and c/d in the sense that we are looking for the

smallest fraction that both a/b and c/d divide into giving integers.

Example: 15/77 and 25/49 and see if 75/7 does the trick.

(75/7)/(15/77)=(75*77)/(7*15)=5*11=55 and (75/7)/(25/49)=(75*49)/(25*7)=3*7=21

which yields integral values for each division.

x x

So given ------ + ------- = 7 and multiplying both sides by 75/7 we obtain

15/77 25/49

55x + 21x = 7*(75/7) = 75

x = 75/76

It looks like **lcm(a/b,c/d) = lcm(a,c)/hcf(b,d)**

Example: lcm(1/4,1/6) = lcm(1,1)/hcf(4,6) = 1/2. (1/2)/(1/4)=2 and (1/2)/(1/6) = 3.

Example: lcm(4,6) = lcm(4/1,6/1) = lcm(4,6)/hcf(1,1) = 12/1 = 12. (Works for integers)

Example: lcm(2/3,6/15) = lcm(2,6)/hcf(3,15) = 6/3 = 2

2/(2/3) = 3 and 2/(6/15) = 5

Hmmmmmm. This might at times be an easier approach to solving equations involving fractions.

But of course for just two fractions we could replace lcm(a,c) with ac/hcf(a,c) so the formula

would become **lcm(a/b,c,d) = ac/(hcf(a,c)*hcf(b,d))**

And would **lcm(a/b,c/d,e/f) = lcm(a,c,e)/hcf(b,d,f)** etc. for more than two fractions?

Your program is generating some interesting questions!

Writing "pretty" math (two dimensional) is easier to read and grasp than LaTex (one dimensional).

LaTex is like painting on many strips of paper and then stacking them to see what picture they make.

Offline

**noelevans****Member**- Registered: 2012-07-20
- Posts: 236

And again HI!

Do you have a highest common factor (greatest common divisor) calculator too?

It seems to me that "gcd" is preferred more in higher levels of mathematics.

**hcf(a/b,c/d) = hcf(a,c)/hcf(b,d).** (Extends to more than two fractions)

These are used in a method of adding and subtracting fractions which is easier to

use in most cases where the denominators have a common factor.

10 15 5 2 3 10 13 130 65

Example: ---- + ---- = --- ( -- + -- ) = --- x --- = ---- = ---

33 22 11 3 2 11 6 66 33

The 5/11 is the hcf of 10/33 and 15/22.

The 66 in the 130/66 is the least common denominator of the fractions, but if

one cancels out the 2 from the 10 and 6 before multiplying then the 65/33 is

obtained thus bypassing the 130/66. Thus the least common denominator is

not necessarily seen in the process.

Any non-zero linear combination of two (or more) natural numbers M and N, say aM+bN

where a and b are non-zero integers has as one of its factors hcf(M,N).

If c is a common factor of of M and N then there are numbers x and y such that

M=cx and N=cy. Hence aM+bN = axc + bcy = c(ax + by). So ANY common factor

of M and N must be a factor of the linear combination also.

This should also apply to two (or more) fractions a/b and c/d.

I've heard of even and odd fractions, prime and composite fractions, and now lcm

and hcf of fractions. What's next? And what interesting applications might arise from

these concepts?

Have a super day (or night as the case may be)!

I gotta get back to sleep.

LaTex is like painting on many strips of paper and then stacking them to see what picture they make.

Offline

**MathsIsFun****Administrator**- Registered: 2005-01-21
- Posts: 7,559

Yes I have: Greatest Common Factor Calculator

Offline

**noelevans****Member**- Registered: 2012-07-20
- Posts: 236

The gcd calculator seems to work fine for positive integer inputs. I input negative integers, decimals and fractions and it just returned 1 in every case although it allows inputting these (fractions in form a/b) forms. I have written many programs in BASIC and have had to try to "idiot-proof" them. It's difficult to anticipate what other people might do.

Somewhere down the line when you have a good chunk of time (if ever) it would be nice to have a

calculator that allows the input of integers, decimals and fractions as well as positive integers and

then have the program calculate both the lcm and gcd for the input set of numbers. You could

have the first site on the internet that does these calculations for all these kinds of inputs. It might

generate a good bit of curiosity and cause a bit more membership and traffic on the site.

LaTex is like painting on many strips of paper and then stacking them to see what picture they make.

Offline

**MathsIsFun****Administrator**- Registered: 2005-01-21
- Posts: 7,559

The LCM calculator is a Flash App that uses my "full precision" library

But the GCF calculator is a fairly simple javascript program ... I could re-make it in Flash.

Offline

**MathsIsFun****Administrator**- Registered: 2005-01-21
- Posts: 7,559

I adapted the LCM calculator as a GCF calculator!

Here: Greatest Common Factor Calculator

Have a play, tell me what works/doesn't work.

Offline

**Mpmath****Member**- Registered: 2012-10-11
- Posts: 216

Hi MIF;

This is a very good job. Congratulations!

Winter is coming.

Offline

**noelevans****Member**- Registered: 2012-07-20
- Posts: 236

Hello again MIF,

The gcf, gcd, hcf, hcd calculator seems to work just fine. Works with negative numbers and with

decimals too. And if one tries to input fractions with the "/" it just ignores the "/". Good work!

I'm still working on the lcm and gcd of fractions trying to get equivalent formulations and

examples of problems that it can apply to.

Have a great day!:P

LaTex is like painting on many strips of paper and then stacking them to see what picture they make.

Offline

**noelevans****Member**- Registered: 2012-07-20
- Posts: 236

Hi again!

An interesting note:

Assume a,b,c,d are integers in the following and that the fractions are in reduced form.

(It still seems to work OK even if the fractions are not reduced.)

Using hcf(a/b,c/d)=hcf(a,c)/hcf(b,d) and lcm(a/b,c/d)=lcm(a,c)/hcf(b,d) works for

whole numbers like 10 and 15 written as 10/1 and 15/1.

Example1:

hcf(10,15) = hcf(10/1, 15/1) = hcf(10,15)/hcf(1,1) = 5/1 = 5.

lcm(10,15) =lcm(10/1, 15/1) = lcm(10,15)/hcf(1,1) = 30/1 = 30 and hcf*lcm=5*30=150=10*15

So whole numbers (and so also integers) also work under the definition of hcf for fractions

with the usual M*N=lcm(M,N)*hcf(M,N) formula intact.

BUT for other kinds of fractions this product of the original two numbers equals the product

of the hcf and lcm does NOT necessarily work.

Example2: hcf(1/10, 1/15) = hcf(1,1)/hcf(10,15) = 1/5.

lcm(1/10,1/15) = lcm(1,1)/hcf(10,15) = 1/5

so hcf*lcm = (1/5)(1/5)=1/25 whereas (1/10)(1/15) = 1/150. The hcf*lcm is missing the other

factor of each of the 10 and 15. So we only get the 5 and 5 but not the other factors 2 and 3.

Example3: hcf(15/8, 25/6) = hcf(15,25)/hcf(8,6) = 5/2.

lcm(15/8, 25/6) = lcm(15,25)/hcf(8,6) = 75/2.

so hcf*lcm = 375/4 whereas (15/8)(25/6)=375/48. So again we are missing the other factors

in the denominator. The numerators are always the same since they are a product of the lcm

and hcf of INTEGERS.

So it looks like in the case of integers, we get hcf(M,N)*lcm(M,N)=M*N as a SPECIAL CASE of the

more general definition of lcm and hcf because the denominators are both 1's.

Example4: hcf(10/7, 15/7)=hcf(10,15)/hcf(7,7) = 5/7.

lcm(10/7, 15/7)=lcm(10,15)/hcf(7,7) = 30/7.

So hcf*lcm = (5/7)(30/7) = 150/49 and (10/7)(15/7) = 150/49.

So if BOTH denominators are the SAME then the product of the original numbers = lcm*hcf holds.

Example5: hcf(10/3, 15/7)=hcf(10,15)/hcf(3,7) = 5/1 = 5.

lcm(10/3, 15/7)=lcm(10,15)/hcf(3,7) = 30/1 = 30.

so hcf*lcm = 5*30=150 whereas (10/3)(15/7)=150/21 Again these are not equal.

CONCLUSION1: THE lcm*hcf BEING EQUAL TO THE PRODUCT OF THE original two numbers

ONLY WORKS WHEN THE TWO NUMBERS HAVE THE same DENOMINATOR.

Of course, integers are written over 1 to make them fractions for the formula.

CONCLUSION2: The old trick of calculating the lcm by dividing the product of the original numbers

by the hcf cannot be used when dealing with fractions unless their denominators

are the same.

CONCLUSION3: Given fractions a/b and c/d with a,b,c,d integral the equality

lcm(a/b, c/d) = a*c/(hcf(a,c)*hcf(b,d)) is I believe true because we can

substitute lcm(a,c) = a*c/hcf(a,c) since a and c are integers.

CONCLUSION4: Given a/b and c/d if gcd(b,d)=1 then the lcm and hcf of the two fractions are

integers. See example 5. Furthermore they are the lcm and hcf of just the

numerators.

So MIF, can I blame my lack of sleep on you? You really got my mind a buzzin' with your lcm

calculator!

P.S. The decimals seem to still work for the lcm and gcd calculators and seem to give the same

answer when changed into fractions.

LaTex is like painting on many strips of paper and then stacking them to see what picture they make.

Offline