0

I was solving this problem: how many odd numbers are there, with five digits, in which the sum of the digits in the units and tens places is 16 and the sum of all the digits is a multiple of 5? I'm considering using the combination with repetition method. Here's my train of thought:

$$ \underline{a} \quad \underline{b} \quad \underline{c} \quad \underline{d} \quad \underline{e}$$

I started by setting up the equation: $a + b + c + 1 + (10 + 5) = 5k$, $k \in \mathbb{Z}$, where $a, b, c,d$, and $e$ represent the digits of the five-digit number, and $k$ is an integer.

However, I encountered a new scenario where $d$ and $e$ could be either $(9, 7)$ or $(7, 9)$. I'm unsure if applying the combination with repetition method efficiently addresses this.

How do I apply the stars and bars method to solve this problem? I understand that I need to find the total solutions and then subtract the number of solutions where at least one variable is at least 10.

Attempt: Since $a$, $b$, and $c$ are digits, their values cannot exceed $9$. I'm considering the cases where $a + b + c = 5q - 1 \leq 27$. Since $a, b,c$ are odd, the sum cannot be even. Thus, I'm calculating the combinations for $a + b + c = 19$, (when $q = 4$) and $a + b + c = 9$, (when ($q = 2$)).

  • "Since a,b,c are odd" a,b and c dont have to be necessarily odd for the whole number to be odd – EnEm Jun 01 '24 at 18:13
  • @EnEm There was a small mistake on my part... I considered all the odd digits, when only the number abcde is odd – Gjhdby5 Vjfhu Jun 01 '24 at 18:18

2 Answers2

1

The majority of this response discusses the use of Stars and Bars to conquer the problem. In fact, it wasn't until I saw the answer of true blue anil that I started thinking of a much easier approach. First see my Addendum, at the end of this answer.

The answer of true blue anil has since been deleted. I regard this alternative approach, that was inspired by the answer of true blue anil before that answer was deleted, that does not use Stars and Bars theory, as (by far) the most elegant approach.

Then, you can examine the remainder of my answer for the (somewhat primitive) use of Stars and Bars theory to attack the problem.


I am going to assume that a specific digit can occur more than once in the 5 digit number. For example, the 5 digit number can have two 1's in it. I will also assume that the leftmost digit can be $~0.~$ Then, at the end of my answer, I will adjust the computation, to assume that the leftmost digit can not equal $~0.$

You have that $~(d,e) \in \{(9,7),(7,9)\} ~: ~2 ~$ possibilities.

Further, regardless of whether $~(d,e) = (9,7),~$ or $~(d,e) = (7,9),~$

you then have that

$$(a + b + c) \equiv 4 \pmod{5}. $$

This implies that $~(a + b + c)~$ must be an element in $\{4, 9, 14, 19, 24\}.$

The above constraint can be re-stated as

$$~(a + b + c) = (4 + 5k) ~: ~k \in \{0,1,2,3,4\}. \tag1 $$

Now, Stars and Bars theory can be used to enumerate the number of all possible satisfying ordered triplets $~(a,b,c).~$ There is a complication however. Inclusion-Exclusion will also be involved, because each of the variables $~a, ~b, ~$ and $~c~$ has an upper bound of $~9.~$

I am going to follow the model in this answer to attack the problem.

Here, if you ignore the presence of upper bounds, you have that for each value of $~k,~$ the total number of solutions is the same as the number of solutions to

  • $a + b + c = 4 + 5k.$

  • $a, ~b, ~c \in \Bbb{Z_{\geq 0}}.$

By basic Stars and Bars theory, the number of solutions is

$$\binom{[4 + 5k] + [3-1]}{3-1} = \binom{6 + 5k}{2}.$$

Therefore, the preliminary computation, that ignores the existence of upper bounds on $~a, ~b, ~c~$ is

$$\sum_{k=0}^4 \binom{6 + 5k}{2}. \tag2 $$

Clarification
If there was no concern about upper bounds on $~a, ~b, ~c~$ and if the left most digit was permitted to equal $~0,~$ then the final computation would be

$$2 \times \left[ ~\sum_{k=0}^4 \binom{6 + 5k}{2} ~\right].$$


For this particular problem, the easiest way to adjust for the presence of upper bounds on the variables $~a, ~b, ~c$ is by considering each of the values $~k \in \{0,1,2,3,4\},~$ separately.

For $~k \in \{0,1\},~$ you have that $~0 \leq (4 + 5k) < 10.~$

Therefore, for $~k \in \{0,1\},~$ it is impossible for any satisfying ordered triple $~(a,b,c)~$ to have any of its variables be $~\geq 10.~$

For $~k \in \{2,3\},~$ you have that $~10 \leq (4 + 5k) < 20.~$

Therefore, for $~k \in \{2,3\},~$ for any satisfying ordered triple $~(a,b,c),~$ you can not have more than one of these variables be $~\geq 10.~$

So, you can reserve the factor of $~3,~$ and then assume, without loss of generality, that $~a \geq 10.~$

So, when $~k \in \{2,3\},~$ the number of solutions to deduct is the same as the number of solutions to

  • $a + b + c = (4 + 5k)$

  • $a \in \Bbb{Z_{\geq 10}}$

  • $b,c \in \Bbb{Z_{\geq 0}}.$

The standard adjustment here is $~y = (a - 10) \implies y \in \Bbb{Z_{\geq 0}}.$

So, ignoring the reserved factor of $~3,~$ with $~k \in \{2,3\},~$ you are now computing the number of solutions to

  • $y + b + c = (4 + 5k) - 10 = (5k - 6).$

  • $y \in \Bbb{Z_{\geq 0}}$

  • $b,c \in \Bbb{Z_{\geq 0}}.$

By basic Stars and Bars theory, the number of solutions to deduct, when $~k \in \{2,3\},~$ is (remembering the reserved factor of $~3$):

$$3 \times \binom{[5k - 6] + [3-1]}{3-1} = 3 \times \binom{5k - 4}{2}.$$

So, at this point in the analysis, the computation in (2) above has been adjusted to

$$\left[ ~\sum_{k=0}^4 \binom{6 + 5k}{2} ~\right] - \left[ ~3 \times \sum_{k=2}^3 \binom{5k - 4}{2} ~\right]. \tag3 $$


It remains to consider how many solutions need to be deducted for $~k = 4 \implies (5k + 4) = 24.$

Here, I am going to implement Inclusion-Exclusion more formally.

Let $~S~$ denote the collection of all ordered triplets $~(a,b,c)~$ such that $~a,b,c \in \Bbb{Z_{\geq 0}},~$ and $~a + b + c = 24.$

Let

  • $S_1~$ denote the subset of $~S~$ where $~a \geq 10.~$

  • $S_2~$ denote the subset of $~S~$ where $~b \geq 10.~$

  • $S_3~$ denote the subset of $~S~$ where $~c \geq 10.~$

Then, the number of solutions to deduct is

$$|S_1 \cup S_2 \cup S_3|. \tag4 $$

Note that since $~(3 \times 10) > 24, ~$ you have that $~|S_1 \cap S_2 \cap S_3| = 0.$

Then, from Inclusion-Exclusion theory, and by considerations of symmetry, you have that the expression in (4) above is equivalent to

$$[ ~3 \times | ~S_1 ~| ~] - [ ~3 \times | ~S_1 \cap S_2 ~| ~].$$

Using analysis very similar to the analysis when $~k \in \{2,3\},~$ you have that the number of solutions to deduct here is

$$3 \times \left[ ~\binom{16}{2} - \binom{6}{2} ~\right].$$

So, at this point the total number of satisfying solutions $~(a,b,c)~$ may be expressed as

$$N = \left[ ~\sum_{k=0}^4 \binom{6 + 5k}{2} ~\right] - \left[ ~3 \times \sum_{k=2}^3 \binom{5k - 4}{2} ~\right]$$

$$- \left\{ ~3 \times \left[ ~\binom{16}{2} - \binom{6}{2} ~\right] ~\right\}.\tag5 $$

Therefore, assuming that $~0~$ is allowed to be the leftmost digit, the enumeration of satisfying digits is

$$2 \times N.$$


It now remains to provide the separate answer, under the assumption that the leftmost digit is not permitted to equal $~0.~$

The easiest way of doing this is to compute the number of satisfying solutions $~(a,b,c)~$ where $~a = 0.~$ Denoting this computation as $~D,~$ then the final answer here will be

$$2 \times ( ~N - D ~).$$

With $~a = 0,~$ and $~b + c \equiv 4 \pmod{5},~$

you have that $~(b + c) = (4 + 5l) ~: ~l \in \{0,1,2\}.$

So, you temporarily ignore that $~b,c~$ have an upper bound of $~9,~$ and you enumerate the number of solutions to

  • $b + c = (4 + 5l).$

  • $b,c \in \Bbb{Z_{\geq 0}}.$

By Stars and Bars theory, the computation of $~D~$ therefore starts with

$$\sum_{l = 0}^2 \binom{5 + 5l}{1} = \sum_{l=0}^2 (5 + 5l).$$

Then, very similar to the adjustments made to $~N,~$ you have to adjust for when $~l = 2,~$ and one of the variables $~b,c~$ is $~\geq 10.~$

The amount to deduct from $~D~$ will be

$$2 \times (10 - 5) = 10.$$


Now, the final computation may be provided, under the assumption that $~0~$ is not permitted to be the leftmost digit:

$$N = \left[ ~\sum_{k=0}^4 \binom{6 + 5k}{2} ~\right] - \left[ ~3 \times \sum_{k=2}^3 \binom{5k - 4}{2} ~\right]$$

$$- \left\{ ~3 \times \left[ ~\binom{16}{2} - \binom{6}{2} ~\right] ~\right\}.$$

$$D = \left[ ~\sum_{l=0}^2 (5 + 5l) ~\right] - 10.$$

The final computation is

$$2 \times (N - D).$$


$~\underline{\text{Addendum}}$

See also the comment that I left, following the answer of true blue anil. You can construe part of the problem as a probability problem. At random, the probability of any 3 digit number having the sum of its digits being congruent to $~4 \pmod{5}~$ is $~\dfrac{1}{5}.~$

This can be demonstrated by partitioning the $~900~$ elements in the set $~\{100,101,\cdots,999\},~$ into subsets of $~10~$ each, of form $~10k + r ~: ~r \in \{0,1,\cdots,9\}.$

Then, in any such subset of $~10~$ elements, exactly $~2~$ of the $~10~$ elements will have the sum of their digits congruent to $~4 \pmod{5}.$

user2661923
  • 42,303
  • 3
  • 21
  • 46
  • Doesn't your addendum solve the whole problem, without need for any of the rest? Both result in $360$ solutions. – Eric Snyder Jun 02 '24 at 04:43
  • @EricSnyder Yes, but the original poster's question was not how to solve the problem. Instead, the original poster asked how Stars and Bars theory can be used to solve the problem. Beyond that, as I indicated, I didn't think of the answer in the Addendum, until I had written everything else, and happened to glance at the (now deleted) answer of true blue anil. So, I left the Stars and Bars theory in, for the educational value. – user2661923 Jun 02 '24 at 06:08
0

Why must you use stars and bars ? I think it is better solved using commonsense.

  • The last two digits must either be $97$ or $79$, and they both satisfy the "odd number" constraint, but have a "shortfall" of $4$ to be evenly divisible by $5$

  • So if $N$ is the number formed by the first three digits, it must leave a remainder $4$ when divided by $5$, starting from $103$
    so $N= 103 +5k \leq 999 \rightarrow k\leq179$

  • Thus there will be $180$ three digit numbers that are valid

  • Finally, answer = $180\cdot 2=360$


Added

In actuality, there would be two streams mod $9$, one being $4(mod\; 9), eg\; 103, 112, 121...$
and the other being $0(mod\; 9), eg\; 108,117,126,..$ but together they amount to the artifice of just counting from $103$ by $5s$
The addendum of @2661923 using probability is another good way of looking at it.

The bottomline is that the answer is $360$ and that using stars and bars here unnecessarily complicates the solution.

  • See the start of my answer, and the Addendum, at the end of my answer. You can skip everything else. I agree that your common sense approach is best, by far. However, I think that the number of satisfying 3 digit numbers is $~180.~$ – user2661923 Jun 01 '24 at 20:55
  • @2661923: Starting with $400$ was incorrect, and the final ans is $180\times 2$. I am amending, thanks – true blue anil Jun 01 '24 at 21:15
  • I still question your logic. You don't want the 3 digit number to be congruent to $~4 \pmod{5},~$ but rather the sum of its digits to be congruent to $~4 \pmod{5}.~$ So, the first four satisfying numbers are $~{103, 108, 112, 117}.~$ These numbers do not vary by $~5.~$ Personally, I don't see how that you can avoid the analysis in my Addendum. – user2661923 Jun 01 '24 at 21:18
  • You need the $~5~$ digit number to have the sum of its digits divisible by $~5.~$ Since the sum of the two rightmost digits is $~16,~$ the sum of the three leftmost digits must be congruent to $~4 \pmod{5}.~$ So, the smallest satisfying 5 digit numbers are $~10379, 10397, 10879, 10897, 11279, 11297.$ The jump from $~108~$ to $~112~$ is not equal to $~5.$ – user2661923 Jun 01 '24 at 21:32
  • Hmm, am deleting for the nonce, watching French Open. WIll have a look when undistracted ! – true blue anil Jun 01 '24 at 22:23
  • @user2661923: Sorry, I got distracted , I have put in an Added part which hopefully clears the confusion. Your Addendum is a good approach. You might consider putting it as the main approach with stars and bars as an Addendum (+1) – true blue anil Jun 02 '24 at 07:09