# The biggest number $N$ that satisfies certain requirements.

The problem is as such:

Say a natural number $$n$$ as special if it does not have the digit $$0$$, has $$2021$$ as the sum of its digits, and the sum of the digits of $$2n$$ does not exceed 1202. Let $$N$$ be the largest number that is special. How many digits does $$N$$ have?

I thought to let $$N = a_k10^k + a_{k-1}10^{k-1}+\dots+a_210^2+a_110+a_0$$. This way, the requirements become:

• $$a_i\neq0$$ for $$i=\{1,2,\dots k\}$$.
• $$a_1+a_2+\dots\ a_k=2021$$ for $$1\leq a_1,a_2,\dots,a_k\leq 9$$.
• $$2a_1+2a_2+\dots+2a_k\leq1202$$ for $$1\leq a_1,a_2,\dots,a_k\leq 9$$.

I have tried to meddle with the second and third using stars and bars, but I met a deadend. Help would be appreciated, thanks.

• The sum of the digits of $2N$ is not necessarily $2a_1+ \cdots +2a_k$. For example, $15$ has a digit sum of $6$ and $2(15)=30$ has a digit sum of $3$. Commented Mar 31, 2023 at 3:43
• Ah, I forgot to consider that. Thanks. Commented Mar 31, 2023 at 3:53
• $316$ fives, followed by $441$ ones, gives digit sum $5\times316+441=2021$, and twice that number has $316$ ones and $441$ twos, sum $316+882=1198$. Commented Mar 31, 2023 at 4:55
• How can I be sure that is the largest such $N$? Commented Mar 31, 2023 at 8:12
• I didn't say that it is. But it does give you something to think about, doesn't it? Commented Mar 31, 2023 at 12:34

Assume $$M$$ is the largest number.

Step $$1$$:

$$M$$ cannot contain $$2,3,4$$ as its digits. For example, if $$M=a...b4c ...d$$, then $$M=a...b1111c...d$$ is a greater number which satisfies both of the required conditions.

Step $$2$$:

$$M$$ cannot contain $$6,7,8,9$$ as its digits. For example, if $$M=a...b7c ...d$$ ($$M=a...b8c...d$$), then $$M=a...b115c...d$$ ($$M=a...b1115c...d$$) is a greater number which satisfies both of the required conditions.

Conclusion:

$$M$$ only contains $$5$$ and $$1$$.

Step $$3$$:

$$M$$ is comprised of $$m$$ fives and $$n$$ ones ($$5m+n=2021$$), and the sum of the digits of $$2M$$ is $$m+2n.$$

Step $$4$$:

Our goal is to maximize $$m+n=m+(2021-5m)$$ where $$m+2n=m+2(2021-5m) \leq 1202.$$

Step $$5$$:

From $$m+2(2021-5m) \leq 1202$$, we conclude that $$316 \leq m$$, which implies that the maximum of $$m+n=m+(2021-5m)$$ happens at $$m=316$$ and $$n=441$$.

• Ha! I got it right! Commented Apr 1, 2023 at 11:59

Hints towards a solution. If you're stuck, explain what you've tried.

• Prove that if $$n$$ has $$c_i$$ digits that are $$i$$, then $$2n$$ has digit sum $$2c_1 + 4c_2+6c_3+8c_4 + 1c_5 + 3c_6+5c_7+7c_8 + 9c_9$$.
• This is the crux. Think about why we'd be interested in something like this, and how you could come up with it.
• Hence, what can you say about $$c_1 + 2c_2 + 3c_3 + 4c_4$$?
• What can you say about $$5c_5+ 6c_6 + 7c_7 + 8c_8 + 9c_9$$?
• Under these constraints, what is the maximum number of digits ($$\sum c_i)$$?
• Hence, what is the maximum $$n$$?