Saturday, September 5, 2015

GCFLCM.C: Greatest Common Factor and Least Common Multiple Calculator

Output
GCFLCM.C

How to Use

  • This can accept two or three inputs. The last one is optional.
  • Please input your integer from the left, in this order:
    i-1i-2i-3 (optional).
  • Type the integer on each input. Minimum value of 1.
    The maximum value:
    1. For 2 inputs: i-1 and i-2 can accept (up to) 10,000.
    2. For 3 inputs: each input accepts maximum value of 500.
    Then hit either "gcf" or "lcm" to calculate.
  • Hit "reset" to reset all.

Purpose

This tool can be used to teach kids about finding the GCF and LCM.
Or maybe as a reminder if you forgot the method.

Example
We wanna find the GCF and LCM from 4 and 14.
First, get the Prime factorization from both.
We can use that tree factoring method, which yields:
  • 4 = 2 * 2 (or 22)
  • 14 = 2 * 7

GCF

GCF is about the least exponent of the same factors.
Or, the largest shared common factors which can be used to divide each of the numbers without resulting remainders.

Thus, as you can see, they have the common factors of 2.
The 2 and 22.

Take the one with the least exponent.
That's the GCF, 2.

If we divide 4 or 14 by 2, each division won't produce remainders.
But if we use the 22 or 7 as the divisor, one of the divisions will result remainders.

LCM

LCM is about the highest exponent of the same factors multiplied by the different factor(s).
Or, the least positive integer which can be divided by all input numbers.

Take a look again, they share the common factors of 2 and one difference, 7.
For the same factors, take the one with the largest exponent, that is 22.
For the difference, just take that into the multiplication.
Then the LCM is 22 * 7 = 4 * 7 = 28.

In another words:
  • The multiples of 4 = 4, 8, 12, 16, 20, 24, 28, 32, ...
  • The multiples of 14 = 14, 28, 42, ...
Therefore, 28 is the least common multiple of 4 and 14.

No common Prime factor?

Then the GCF will be 1, and the LCM will (still) be the method above.
For example, 3 and 5.
  • The GCF is 1.
  • The LCM is 15 (3 * 5).
    —The multiplication of different factors.

Why is this important?

Well, it's not, but ya know, for weird fun.
Suppose one day there's GCF and LCM mob rampage. Then you're ready to punch those sons of in the. Then live happily ever lasting.

Also, either GCF or LCM or both is/are used unconsciously in many fields of engineering.
More like reflex. Or completely not.

JavaScript Library

This tool is using Math Operations for the GCF and LCM methods (and adding comma to large integer).
The Prime factorization method is from Prime Factorization-er tool below.