Divisibility Rules Calculator & Missing Digits
Use familiar divisibility rules and verify them with a digit-by-digit trace for any supported divisor. Replace digits with question marks to find how many completions pass all selected divisors. Compare the first and last match, and inspect how many completions use each digit in each unknown position.
Test divisibility and solve for missing digits
Check a whole number or find every way to fill a digit pattern that passes your divisors.
Number and divisors
Enter up to 64 digits. Use ? for each unknown, and separate 1–6 divisors with commas or spaces.
Multiple completions pass every divisibility test.
Matching completions
- Combined divisor
- 36
- Number of matches
- 3
- First completion
- 12240
- Last completion
- 12744
Which digits can fit?
Count the valid completions with each digit in the selected position. Every other unknown digit can vary.
The tallest bar represents 1 match.
- Digit 0
- 0
- Digit 1
- 0
- Digit 2
- 1
- Digit 3
- 1
- Digit 4
- 0
- Digit 5
- 0
- Digit 6
- 0
- Digit 7
- 1
- Digit 8
- 0
- Digit 9
- 0
Follow the remainder
Using first match 12240
The final two digits, or all digits if shorter, are 40. They have the same remainder modulo 4.
Step 5: (10 × 0 + 0) mod 4 = 0
Full-number remainder: 0
Export the divisibility worksheet
The CSV includes exact counts and prefix remainders. Import number and count columns as text to preserve long values and leading zeros.
View CSV text
How to use this calculator
- Enter a whole number or replace each missing digit with a question mark.
- Enter one to six divisors. Enable leading zeros for fixed-width digit strings.
- Read the known number’s individual remainders, or inspect the match count and first and last completions for a digit pattern.
- Choose an unknown digit position to see its counts. Choose a divisor and a prefix step to trace the first match or entered number.
- Download the worksheet to keep all exact counts and trace steps.
The Formula
The mathematical logic powering this calculation is:
The remainder starts at zero. After appending digit d to a prefix with remainder r modulo m, its new remainder is (10r + d) mod m. If the final remainder is zero, the number is divisible by m. For 3 and 9, 10 is congruent to 1, so a digit sum preserves the remainder. For 11, 10 is congruent to −1, so the alternating sum starting with a positive sign at the right does the same. Last-digit rules follow when the divisor divides the corresponding power of ten.
All entered tests pass exactly when the number is divisible by the least common multiple M of your divisors. For missing digits, start at the end of the pattern where remainder 0 has one valid completion and other remainders have none. For each earlier position and each incoming remainder r, sum the suffix counts for every allowed digit d continued at (10r+d) mod M. The start count at remainder 0 is the exact number of matches.
Each position's digit tally counts valid prefixes leading into the chosen digit times valid suffixes after the digit. The ten digit tallies at any unknown position sum to the total match count. For the first or last completion, choose the smallest or largest digit with a valid suffix at each step.
Use 1–64 nonnegative decimal digits and question marks. Enter up to six divisors from 1 to 999. A pattern with a question mark supports a combined divisor up to 2,000. Allow leading zeros to work with fixed-width digit strings. A single zero passes every positive divisor. The CSV stores exact values; choose text types on spreadsheet import to preserve leading zeros and long integers.Worked Example
If you input:
- Pattern: 12?4?
- Divisors: 4 and 9
Result:
Three completions pass both tests: 12240, 12348 and 12744. The joint test is divisibility by 36.
Frequently Asked Questions
What is the divisibility rule for 9?
Add the decimal digits. If the sum is divisible by 9, the original number is also divisible by 9. For example, the digits of 12240 sum to 9.
Can I have more than one missing digit?
Yes. Each question mark is a separate unknown position. All valid completions are counted, and the chart shows how many matches use each digit in the selected position.
Why use the least common multiple for multiple tests?
An integer passes every divisibility test exactly when it is a multiple of their least common multiple. Repeated divisors and shared factors do not change this condition.
Does 0 count as divisible?
Yes. Its quotient is zero and its remainder is zero for any positive divisor. An all-zero fixed-width string represents the same integer when leading zeros are allowed.
Similar Calculators
Linear Congruence Calculator & Solution Timeline
Solve one or more linear congruences ax ≡ b (mod m). Find the common residue and period, or see why the congruences conflict.
Prime Factorization Calculator
Find the prime factors of any whole number and express it as a product of prime numbers.
GCF Calculator
Find the greatest common factor (GCF) of two or more integers.
