In mathematics, we use and follow algorithms all the time. We follow steps and processes to calculate and solve problems. A great example to look at is using algorithms to determine whether a number is divisible by other numbers. We call these divisibility tests.
Let's begin with a simple divisibility test.
How do you know if a number is divisible by 10? That's easy, right? You just check to see if it ends in a zero. That's an algorithm right there. You just specified a test and a check to sort numbers for those that are divisible by 10 and for those that are not. It's a type of search and sort algorithm.
To test whether numbers are divisible by 2, 4, 5, or 8, we have similar very simple algorithms to follow:
If a number is divisible by 2, then the number ends with an even numbe
If the last two digits are divisible by 4, then the whole number is divisible by 4.
If a number is divisible by 5, then the number ends in a 0 or a 5
If the last three digits are divisible by 8, then the whole number is divisible by 8.
To test whether a number is divisible by 3, we use the following algorithm:
Find the sum of the digits of the number.
If the sum is a multiple of 3, then the number itself is a multiple of 3.
To test whether a number is divisible by 9, we use the following algorithm:
Find the sum of the digits of the number.
If the sum is divisible by 9, then the number is also divisible by 9.
To test whether a number is divisible by 6, we use the following algorithm:
Test whether the number is divisible by 2.
Test whether the number is divisible by 3.
In the question set you'll see a few others that we haven't seen here, so just follow the steps to use them.
Consider the following numbers: 940, \, 257, \, 8535,\, 486,\, 1923,\,11\,705,\, 21\,735,\, 92\,872,\, 98\,941,\, 77\,990,\, 2327, \, 6644, \, 985, \, 605, \, 8470
List all the numbers that are divisible by 10.
List all the numbers that are divisible by 5.
List all the numbers that are divisible by 2.
List all the numbers that are divisible by 10, 5 and 2.
To test whether a number is divisible by 6, we use the following algorithm:
Step 1: Test whether the number is divisible by 2.
Step 2: Test whether the number is divisible by 3.
Step 3: If the number is divisible by both 2 and 3, then the number is divisible by 6.
Consider the number 42\,765.
Is 42\,765 divisible by 2?
Is 42\,765 divisible by 3?
Is 42\,765 divisible by 6?
Divisibility tests are types of algorithms.