How to Count Integers Not Divisible by 5
At a glance
- 1. Count the total
Find how many integers are in the specified range.
- 2. Count multiples of 5
Use the fact that an integer is divisible by 5 exactly when it ends in 0 or 5.
- 3. Subtract
Subtract the number of multiples from the total.
- 4. Check the endpoints
Make sure the range includes exactly the intended first and last integers.
To count integers that are not divisible by 5, use the complement principle: count all the integers in the range, count the multiples of 5, and subtract. This works for any finite interval. If the question instead asks you to build numbers from digits, use the same divisibility rule by focusing on the final digit.
The complement method
An integer is divisible by 5 if and only if its final digit is 0 or 5. Thus, among a specified set of integers, the ones divisible by 5 form the part to exclude.
For the integers from 1 through a positive integer , there are numbers in total. The multiples of 5 are , so there are of them. Therefore,
Here, means the greatest integer less than or equal to . It accounts for the fact that the last multiple of 5 may be below .
A worked example: integers from 1 to 100
There are 100 integers from 1 through 100. The multiples of 5 in this range are , or numbers. Subtracting gives
So 80 integers from 1 through 100 are not divisible by 5.
This also matches the last-digit rule: in each block of ten consecutive integers, two numbers end in 0 or 5, leaving eight that do not. Ten such blocks contain numbers.
Counting in an arbitrary interval
Suppose you want to count integers from through , including both endpoints, where . First count the integers in the interval: there are . The number of multiples of 5 in that interval is
Subtract that count from the total:
For example, from 37 through 123 there are integers. The multiples of 5 are counted by
Therefore, integers in that interval are not divisible by 5.
The floor formula also works for negative integer endpoints. For example, it counts multiples such as and as divisible by 5. If your range includes zero, remember that zero is divisible by 5, so it belongs among the numbers being subtracted.
If you are forming numbers from digits
Sometimes the task is not to count every integer in a consecutive range, but to form numbers using a set of digits. In that case, the final digit determines divisibility by 5. For example, consider three-digit numbers made from the digits 0 through 9, with repetition allowed. The first digit has 9 choices (1 through 9), the middle digit has 10 choices, and the last digit has 8 choices if the number must not be divisible by 5 (any digit except 0 and 5). The multiplication principle gives
So there are 720 such three-digit numbers. If repetition is forbidden, or if the allowed digit set differs, the choices for earlier positions may depend on which digits have already been used. In that case, count valid choices position by position and avoid treating dependent choices as independent.
Common mistakes
- Dividing by 5 without checking the range. The number of multiples is for 1 through , not necessarily exactly .
- Forgetting an endpoint. The inclusive interval from to contains integers, not .
- Counting only numbers ending in 5. Numbers ending in 0 are also divisible by 5.
- Using the range formula for a digit-construction problem. If numbers are formed from restricted digits, count valid choices for each position instead of counting a consecutive interval.
- Ignoring zero or negative numbers when they are included. Zero and every integer multiple of 5 are divisible by 5.
Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.