How many 4-digit number exists , such that the sum of it's digit is $29$ & also the number is divisible by $29$?

I literally don't know how to approach this question . What is the basic concept that would be used in solving these type of questions ?Please let me know !!


2 Answers 2


the smallest four digit number which is divisible by $29$ is $1015$. Hence all your numbers are of the form $1015+29k$.

Now, the digit sum is $29$ which implies that the iterated digit sum is $2$, thus we only want to consider numbers which are $2\pmod 9$. The smallest number of the form $1015 +29k$ with this property is $1073$. Thus all your numbers are of the form $1073+(29\times 9)k=1073+261k$.

There are only $35$ such numbers and it is now easy to check by hand (well, tedious but doable with pencil and paper. Effortless with a calculator). We see that the only examples are $$\{4988,7598,7859,9686,9947\}$$

  • $\begingroup$ great answer with least thought! $\endgroup$
    – vidyarthi
    Oct 12, 2016 at 17:59
  • $\begingroup$ very nice answer. I like your solution way better than mine. $\endgroup$
    – felasfa
    Oct 12, 2016 at 18:01
  • $\begingroup$ Well !! A simple elegant solution ... But I don't know the concept of Modular Arithmetic ... If only you could provide me with a source in order to learn Modular Arithmetic ... $\endgroup$
    – Amritanshu
    Oct 12, 2016 at 18:04
  • 1
    $\begingroup$ To get started, I like the Art of Problem Solving. This stuff is a lot of fun, I think you'll enjoy it. $\endgroup$
    – lulu
    Oct 12, 2016 at 18:16

Let's write the number as $abcd$ where $a$, $b$,$c$ and $d$ are the digits. Your condition is equivalent to

\begin{align} a+b+c+d &= 29 \\ 1000a+100b+10c+d &= 29*k \quad k\in \mathbb{N} \end{align}

You have to consider all the possible ways $abcd$ can be arranged and check which ones satisify the above conditions. There is possibly a clever number theoretic inspired algorithm to do this but you can do a brute force approach. The python code below gives me the following result. $$ 4988\quad 7598\quad 7859\quad 9686\quad 9947 $$


import numpy as np

possible_number_list = np.arange(1000,10000,1)

for i in possible_number_list:

    if i%29==0 and sum(int(digit) for digit in str(i))==29:
        print i
  • $\begingroup$ computational number theory! $\endgroup$
    – vidyarthi
    Oct 12, 2016 at 17:59
  • $\begingroup$ vidyarthi yes! lulu's solution is cleaner and smarter $\endgroup$
    – felasfa
    Oct 12, 2016 at 18:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .