Math Is Fun Forum

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

You are not logged in.

#1 2011-05-15 18:05:46

MathsIsFun
Administrator
Registered: 2005-01-21
Posts: 7,713

Least Common Multiple Calculator

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

#2 2011-05-15 19:28:32

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Least Common Multiple Calculator

Hi MIF;

It is a nice little calculator. Very good!


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#3 2011-05-17 05:37:31

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

Re: Least Common Multiple Calculator

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


igloo myrtilles fourmis

Offline

#4 2011-05-17 09:30:15

MathsIsFun
Administrator
Registered: 2005-01-21
Posts: 7,713

Re: Least Common Multiple Calculator

Thanks both.

Quality control smile


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

Offline

#5 2011-05-18 10:07:02

MathsIsFun
Administrator
Registered: 2005-01-21
Posts: 7,713

Re: Least Common Multiple Calculator

Thank You Beth!


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

Offline

#6 2012-10-29 08:47:25

MathsIsFun
Administrator
Registered: 2005-01-21
Posts: 7,713

Re: Least Common Multiple Calculator

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?


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

Offline

#7 2012-10-29 09:57:40

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Least Common Multiple Calculator

Hi;

It is working fine. No problems.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#8 2012-10-29 14:35:55

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

Re: Least Common Multiple Calculator

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.  smile


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

#9 2012-10-29 14:56:29

anonimnystefy
Real Member
From: Harlan's World
Registered: 2011-05-23
Posts: 16,049

Re: Least Common Multiple Calculator

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

#10 2012-10-29 18:19:26

MathsIsFun
Administrator
Registered: 2005-01-21
Posts: 7,713

Re: Least Common Multiple Calculator

I could reject the "-" sign.


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

Offline

#11 2012-10-30 10:54:12

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

Re: Least Common Multiple Calculator

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...  smile


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

#12 2012-10-30 14:25:26

MathsIsFun
Administrator
Registered: 2005-01-21
Posts: 7,713

Re: Least Common Multiple Calculator

Thanks noelevans, well argued and well said.


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

Offline

#13 2012-10-30 16:03:44

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

Re: Least Common Multiple Calculator

Hi again! smile

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! up


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

#14 2012-10-30 20:56:08

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

Re: Least Common Multiple Calculator

And again HI! smile

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. wave  sleep


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

#15 2012-10-31 11:31:23

MathsIsFun
Administrator
Registered: 2005-01-21
Posts: 7,713

Re: Least Common Multiple Calculator


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

Offline

#16 2012-10-31 12:07:54

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

Re: Least Common Multiple Calculator

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.

smile


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

#17 2012-10-31 13:03:31

MathsIsFun
Administrator
Registered: 2005-01-21
Posts: 7,713

Re: Least Common Multiple Calculator

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.


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

Offline

#18 2012-10-31 17:48:16

MathsIsFun
Administrator
Registered: 2005-01-21
Posts: 7,713

Re: Least Common Multiple Calculator

I adapted the LCM calculator as a GCF calculator!

Here: Greatest Common Factor Calculator

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


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

Offline

#19 2012-11-01 09:53:21

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

Re: Least Common Multiple Calculator

Hi MIF;

This is a very good job. Congratulations!


Winter is coming.

Offline

#20 2012-11-01 10:42:03

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

Re: Least Common Multiple Calculator

Hello again MIF, smile

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


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

#21 2012-11-01 15:09:17

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

Re: Least Common Multiple Calculator

Hi again! smile

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!  smile   up   wave

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.


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

Board footer

Powered by FluxBB