[Math] How many 4 digit numbers are divisible by 29 such that their digit sum is also 29

divisibilityelementary-number-theoryrecreational-mathematics

How many $4$ digit numbers are divisible by $29$ such that their digit sum is also $29$?

Well, answer is $5$ but what is the working and how did they get it?

Best Answer

Let the digits be$b,c,d,29-b-c-d$

As $0\le b,c,d\le9,0<b+c+d\le27<29$

Now, $$(29-b-c-d)+10b+100c+1000d=29+9b+99c+999d\equiv-20b+12c-16d$$

We need $29\mid(5b-3c+4d)\equiv-24b-3c+33d\iff29\mid(c+8b-11d)$

For $29\mid(8b-11d)\implies8b-11d=(29k-c)(11\cdot3-8\cdot4)$

$\iff8(b+116k-4c)=11(87k+d-3c)\iff b+116k=11m+4c$

$\iff b\equiv5k+4c\pmod{11}$ and $d\equiv3c+k\pmod{11}$

Test for $c;0\le c\le9$ ensuring $0\le b,c,d\le9$ and $b+c+d\ge20$