|
Divisibility Rules
- For a number to be divisible by 2, it is enough to know that its last
digit is divisible by 2.
- For a number to be divisible by 3, it is enough to know that
the sum of its digits is divisible by 3.
- For a number to be divisible by 4, it is enough to know that
its last two digits are divisible by 4.
- For a number to be divisible by 5, it is enough to check if
its last digit is 5 or 0.
- For a number to be divisible by 6, it is enough to know that
it is divisible by both 2 and 3.
- I don't know any shortcut for 7.
- For a number to be divisible by 8, it is enough to know that
it's last three digits are divisible by 8.
- For a number to be divisible by 9, it is enough to know that
the sum of its digits are divisible by 9.
- For a number to be divisible by 10, it is enough to check if
its last digit is 0.
Here are some more things to think about:
- How would you prove that these techniques are valid?
- Can you think of similar techniques for bigger numbers?
- How can you use these techniques to check if a number is prime?
- What is the minimum number of possible factors you have to check
to see if a given number is prime? (Hint: suppose you've checked whether
or not 2 is a factor of 980258529745894583. Do you then have to check 4?)
Can you use these ideas to improve you program which decides if a given
number is prime?
|