[Math] How many four digit numbers divisible by 29 have the sum of their digits 29

combinatoricselementary-number-theorynumber theory

How many four digit numbers divisible by $29$ have the sum of their digits $29$?

A way to do it would be to write $1000a+100b+10c+d=29m$ and $a+b+c+d=29$ and then form equations like $14a+13b+10c+d=29m'$ and eventually $4a + 3b – 9d = 29 (m'' – 9)$. Analysing this equation for integer solutions using the advantage we have $\to$ $29$ is a prime; will give the solutions, but is tedious work.

Are there better solutions?

Best Answer

If the sum of the digits of $n$ is $29$, then the number $n$ must be congruent to $2$ (modulo $9$). Since $29$ and $9$ are relatively prime, and their product is $261$, we need only consider numbers congruent to $29$ (modulo $261$). There are only about three dozen candidates between $1000$ and $9999$.

Furthermore, the average of the digits is $\frac{29}4>7$; no digit can be $1$, and only one digit can be below $6$. That means we can start our search at $2999$; the first candidate is $3161$, easily discarded, and we just repeatedly add $261$ until we get above $9999$.