Dividing items into groups using a divisor I have a weird problem I'm hoping has a clever math solution! Is there a way to figure out what percentage of large numbers are divisible by a number? For example, what percentage of $8$ digit numbers would be divisible by $7$? How would I figure this out for $X$ digit numbers and other numbers to divide by? Thanks for any help! Rick
 A: Presume your numbers are all between $m$ and $M$. For example, for $8$-digit numbers, $m=10000000, M=99999999$.
Lat $d$ be the number you want to check the divisibility with.
$\lfloor M/d\rfloor$ is the quotient obtained by dividing the largest number $\le M$ divisible by $d$ with $d$. Similarly, $\lceil m/d\rceil$ is the quotient obtained by dividing the smallest number $\ge m$ divisible by $d$ by $d$. Therefore, the number of numbers in the range $[m,M]$ divisible by $d$ is $\lfloor M/d\rfloor-\lceil m/d\rceil+1$.
If you are interested in percentage, it is going to be:
$$\frac{\lfloor M/d\rfloor-\lceil m/d\rceil+1}{M-m+1}\times 100\%$$
Note: the notation $\lfloor x\rfloor$ denotes the largest integer $\le x$. Similarly, the notation $\lceil x\rceil$ denotes the smallest integer $\ge x$.
In your example ($d=7$), $\lfloor M/d\rfloor=14285714$ and $\lceil m/d\rceil=1428572$, so the percentage is $\frac{14285714-1428572+1}{99999999-10000000+1}=\frac{12857143}{90000000}\approx 14.2857144444\ldots \%$, which is very close to $1/7$.
