Calculating with numbers: Computing with integers
The gcd and the lcm
Integers can be placed on a number line, and this also makes clear that you can order them. Negative numbers are to the left of the positive numbers on the number line, and the number is to the left of the number on the number line, as can be seen from the following figure.
Ordering of integers When go on the number line from left the right the integer values increase, for example, the number three is greater than the number two and this is denoted by . When we go on the number line from right to left the integer values decrease, for example is less than and this is denoted by . Symbols for greater than or equal to and less than or equal to are and , respectively.
Minimum and maximum of integers Using the ordering of the set of integers you can define for any two numbers and the minimum and maximum:
The gcd and lcm Two natural numbers could have common divisors. The greatest common divisor (gcd), as the name implies, is their greatest common divisor.
For example , and are divisors of both and . The greatest common divisor of and is . We write this as .
The numbers and only have as common divisor and so their gcd is equal to . We also say that these number relatively prime. In general, we say the following :
Two natural numbers are said to be relatively prime if they have no common factor other than , i.e. if their gcd is equal to .
The least common multiple (lcm) of two natural numbers is, as the name implies, the smallest number that is a multiple of both numbers.
For example, is a multiple of both and and there is no smaller number with this property. We write this as .
Calculation rules for gcd and lcm Let and be natural numbers. Then the following statements for the gcd and lcm are correct.
- .
- If is a common divisor of and then .
- If , i.e. the remainder of dividing by is , then .
- is equal to the product of the highest powers of prime numbers that divide both and .
- is equal to the product of the highest powers of prime numbers that divide or (or both).
- .
The prime factorisations of the given numbers are: For the gcd we take the product of the highest powers of the prime numbers that divide both and . For the lcm we take the product of the highest powers of the prime numbers that divide or (or both). So:
Euclid's algorithm Let and be two natural numbers with (if this condition is not met you just swap the two numbers). The gcd of and can now be calculated as follows:
- Calculate the remainder of divided by .
- Replace by and by .
- Repeat the previous steps until equals .
- The last value of is equal to .