# How many $3$-digit numbers can be formed so that the sum of two digits will be equal to the third digit?

How many $3$-digit numbers can be formed so that the sum of two digits will be equal to the third digit?

I am confused in this question whether to take first 2 digits sum or any digit sum such that it is equal to 3rd digit.

For example, some combinations 112 can be written into 3 ways 112 112 121 such that in the last

Example 3rd number and first number sum = 2 (middle number).

Also, is there any better approach towards this problem rather than counting and arranging the 3 digit number?

• Your confusion is completely reasonable, the problem as quoted is not well-stated and there are at least two reasonable interpretations. Aug 26, 2015 at 14:38
• Have you reproduced the question exactly ? "sum of the 2 digits" is not even proper English. Aug 26, 2015 at 14:39
• @trueblueanil reproduced the correct english form of the question. Aug 26, 2015 at 14:44
• @AndréNicolas yes What to do i think Calculate and See the options side by side Aug 26, 2015 at 14:45
• If you have reproduced, (not changed) to correct English form, I would interpret it as the sum of any 2 digits is equal to the third. Aug 26, 2015 at 14:49

To write the problem in somewhat mathematical terms, we have three digits $d_1 \in \{1, \dots, 9\}$, $d_2,d_3 \in \{0, 1, \dots, 9\}$ that form a $3$-digit number $$x = d_1 \cdot 10^2 + d_2 \cdot 10 + d_3$$ Now, we want to find all possible values of $x$ such that at least one of the following holds:

• $d_1 + d_2 = d_3$,
• $d_1 + d_3 = d_2$,
• $d_2 + d_3 = d_1$

Let's start with the first condition. We may pick $d_1$ freely, which gives us $9$ options. However, since $d_3 \in \{0, 1, \dots, 9\}$, we must always choose $d_2 \in \{0, \dots, 9-d_1\}$. Hence: $$\# \{ x \mid d_1 + d_2 = d_3\} = \sum_{d_i = 1}^{9}(10-d_i) = 45$$ The same reasoning holds for the second condition: $$\# \{ x \mid d_1 + d_3 = d_2\} = \sum_{d_i = 1}^{9}(10-d_i) = 45$$ However, the last condition is different! We pick $d_2$ freely which gives us $10$ options, and we must choose $d_3 \in \{0, \dots, 9-d_2\}$. However, we also have to exclude one case: $d_2 = d_3 = 0$, because then $d_1$ would also be $0$. Hence: $$\# \{ x \mid d_2 + d_3 = d_1\} = \sum_{d_i = 0}^{9}(10-d_i)-1 = 54$$ We now have $45 + 45 + 54 = 144$ numbers $x$ such that either of the conditions hold. However, some numbers are counted twice. It is easy to see that a number is counted twice if and only if $d_i = d_j$ and $d_k = 0$ for $i,j,k$ being some permutation of $1,2,3$. Since $d_1 \neq 0$, the multiples we need to discard are those of the form $d_2 = 0$ or $d_3 = 0$. There are $9$ of each ($d0d$ and $dd0$ with $d = 1, \dots, 9$), so we remove $18$ multiples. There is no number for which all $3$ conditions hold, since that would require $d_1 = d_2 = d_3 = 0$.

The solution is then: $$\#\{x\} = 144- 18 = 126.$$

• You might mention that there are no solutions where all three conditions hold, as you would have to add those back (priciple of inclusion and exclusion) Jul 28, 2016 at 12:23
• @ChristianSievers You're right, I've added that. Jul 28, 2016 at 13:24
• @DPoole Only the condition $d_1 + d_2 = d_3$ holds for that one. Jul 28, 2016 at 13:24

Where X is first digit (1 through to 9) and y is number of digits use equation below and add answers:

             y=  2(9-X) + ( 10-(9-X))


eg X=1 2(9-1) + ( 10 - (9-1)) =18 Then working through remaining first digits: X=2 y=17, X=3 y=16......X=9 y=10 Sum of the Y values is 126

One answer says $126$, the other $135$. Which one is correct?

λ filter (\(a,b,c)->(a+b==c || a+c==b || b+c==a)) [ (x2,x1,x0) | x0 <- [0..9], x1 <- [0..9], x2 <- [1..9] ]
[(1,1,0),(2,2,0),(3,3,0),(4,4,0),(5,5,0),(6,6,0),(7,7,0),(8,8,0),(9,9,0),(1,0,1),(2,1,1),(1,2,1),(3,2,1),(2,3,1),(4,3,1),(3,4,1),(5,4,1),(4,5,1),(6,5,1),(5,6,1),(7,6,1),(6,7,1),(8,7,1),(7,8,1),(9,8,1),(8,9,1),(2,0,2),(1,1,2),(3,1,2),(4,2,2),(1,3,2),(5,3,2),(2,4,2),(6,4,2),(3,5,2),(7,5,2),(4,6,2),(8,6,2),(5,7,2),(9,7,2),(6,8,2),(7,9,2),(3,0,3),(2,1,3),(4,1,3),(1,2,3),(5,2,3),(6,3,3),(1,4,3),(7,4,3),(2,5,3),(8,5,3),(3,6,3),(9,6,3),(4,7,3),(5,8,3),(6,9,3),(4,0,4),(3,1,4),(5,1,4),(2,2,4),(6,2,4),(1,3,4),(7,3,4),(8,4,4),(1,5,4),(9,5,4),(2,6,4),(3,7,4),(4,8,4),(5,9,4),(5,0,5),(4,1,5),(6,1,5),(3,2,5),(7,2,5),(2,3,5),(8,3,5),(1,4,5),(9,4,5),(1,6,5),(2,7,5),(3,8,5),(4,9,5),(6,0,6),(5,1,6),(7,1,6),(4,2,6),(8,2,6),(3,3,6),(9,3,6),(2,4,6),(1,5,6),(1,7,6),(2,8,6),(3,9,6),(7,0,7),(6,1,7),(8,1,7),(5,2,7),(9,2,7),(4,3,7),(3,4,7),(2,5,7),(1,6,7),(1,8,7),(2,9,7),(8,0,8),(7,1,8),(9,1,8),(6,2,8),(5,3,8),(4,4,8),(3,5,8),(2,6,8),(1,7,8),(1,9,8),(9,0,9),(8,1,9),(7,2,9),(6,3,9),(5,4,9),(4,5,9),(3,6,9),(2,7,9),(1,8,9)]

λ length $filter (\(a,b,c)->(a+b==c || a+c==b || b+c==a)) [ (x2,x1,x0) | x0 <- [0..9], x1 <- [0..9], x2 <- [1..9] ] 126  If$x_2 = 0$is allowed, then λ filter (\(a,b,c)->(a+b==c || a+c==b || b+c==a)) [ (x2,x1,x0) | x0 <- [0..9], x1 <- [0..9], x2 <- [0..9] ] [(0,0,0),(1,1,0),(2,2,0),(3,3,0),(4,4,0),(5,5,0),(6,6,0),(7,7,0),(8,8,0),(9,9,0),(1,0,1),(0,1,1),(2,1,1),(1,2,1),(3,2,1),(2,3,1),(4,3,1),(3,4,1),(5,4,1),(4,5,1),(6,5,1),(5,6,1),(7,6,1),(6,7,1),(8,7,1),(7,8,1),(9,8,1),(8,9,1),(2,0,2),(1,1,2),(3,1,2),(0,2,2),(4,2,2),(1,3,2),(5,3,2),(2,4,2),(6,4,2),(3,5,2),(7,5,2),(4,6,2),(8,6,2),(5,7,2),(9,7,2),(6,8,2),(7,9,2),(3,0,3),(2,1,3),(4,1,3),(1,2,3),(5,2,3),(0,3,3),(6,3,3),(1,4,3),(7,4,3),(2,5,3),(8,5,3),(3,6,3),(9,6,3),(4,7,3),(5,8,3),(6,9,3),(4,0,4),(3,1,4),(5,1,4),(2,2,4),(6,2,4),(1,3,4),(7,3,4),(0,4,4),(8,4,4),(1,5,4),(9,5,4),(2,6,4),(3,7,4),(4,8,4),(5,9,4),(5,0,5),(4,1,5),(6,1,5),(3,2,5),(7,2,5),(2,3,5),(8,3,5),(1,4,5),(9,4,5),(0,5,5),(1,6,5),(2,7,5),(3,8,5),(4,9,5),(6,0,6),(5,1,6),(7,1,6),(4,2,6),(8,2,6),(3,3,6),(9,3,6),(2,4,6),(1,5,6),(0,6,6),(1,7,6),(2,8,6),(3,9,6),(7,0,7),(6,1,7),(8,1,7),(5,2,7),(9,2,7),(4,3,7),(3,4,7),(2,5,7),(1,6,7),(0,7,7),(1,8,7),(2,9,7),(8,0,8),(7,1,8),(9,1,8),(6,2,8),(5,3,8),(4,4,8),(3,5,8),(2,6,8),(1,7,8),(0,8,8),(1,9,8),(9,0,9),(8,1,9) λ length$ filter (\(a,b,c)->(a+b==c || a+c==b || b+c==a)) [ (x2,x1,x0) | x0 <- [0..9], x1 <- [0..9], x2 <- [0..9] ]
136


Even if we remove $000$ from the list, which would give $135$ numbers, $011$ is not a $3$-digit number.

• You're right, the answer is indeed $126$. There are $45$ numbers such that $d_1 + d_2 = d_3$, as the accepted answer says, but one cannot simply multiply this by $3$ and claim to have the answer, because the problem is not symmetric due to $d_1 \neq 0$. We may calculate that there are also $45$ numbers such that $d_1 + d_3 = d_2$, but there are $54 = 45 + 9$ numbers such that $d_2 + d_3 = d_1$. This would lead to $45 + 45 + 54 = 144$. However, some numbers are counted multiple times: those of the form $dd0$ and $d0d$. There are $18$ such numbers, so the solution is $144-18 = 126$. Jul 27, 2016 at 12:42
• @SteamyRoot You should post your comment as an answer. Jul 27, 2016 at 13:11

Note: Since, it's not given whether the repetition of digits is allowed or not so I'm solving this by considering repetition to be allowed

The possible combinations can be formed by starting with each of the digits from 1 to 9 so that their sum with the other digit (second digit) is equal to the third digit

(1) Starting with digit 1, possible combinations are: {101,112,123,134,145,156,167,178,189} i.e total number of combinations formed by starting with the digit 1 are 9

(2) Starting with digit 2, possible combinations are: $$\{202,213,224,235,246,257,268,279\}$$ i.e total number of combinations formed by starting with the digit 2 are 8

Proceeding in the same way, we have the total number of combinations formed by starting with the digits $$3, 4, 5, 6, 7, 8, 9$$ are $$7, 6, 5, 4, 3, 2, 1$$ respectively.

Therefore, the total number of such combinations $$= 9+8+7+6+5+4+3+2+1$$ $$= 45$$

Hence, the total number of 3-digit numbers can be formed so that the sum of two digits will be equal to the third digit is 45.

I'm going to assume that the problem means that the sum of any two digits equals the third.

To start, let's find out how many 3 digit numbers have the last digit as the sum of the first two digits:

Here, the first digit cannot be $0$ or $9$. It can't be $9$ because the sum of $9$ and any digit is a two digit number If the first digit is $1$ then second number can be any digit from $0$ to $8$. So nine possibilities. If the first digit is $2$ then the possibities for the second digit is $0$ through $7$.

So, the number of three digit numbers whose first two digits add up to the third is: $9+8+\cdots +1$.

Now, the total of all numbers in which the sum any two digits is 3 times the previous answer because the sum digit could be the first, second or third digit.

• So,according to you Ans is 135 Oct 10, 2015 at 14:17
• Yes. That's what I get. Oct 10, 2015 at 14:21
• Why can't the first digit be 9? 909 has as last digit the sum of the other digits. Jul 28, 2016 at 12:27
• Yes, you are correct. Aug 1, 2016 at 1:26