Numbers $n$ such that $n$ plus the sum of $n$’s digits is $313$

elementary-number-theorynumber theory

Good morning, everyone. Here is the problem I'm faced with:

The sum of the number $n$ and the digits of $n$ equals $313$. What are the possible values of $n$?

By reasoning I concluded that it has to be a $3$ digit number and by hit and trial I found $305$ as one of the answers. How would I find all possible values of $n$?

It would be great if someone could throw light on how to proceed in a mathematical way and get the values of $n$ (as opposed to brute-forcing/trial-and-error).

I tried as below:

Let our number be $xyz$, where $x,y,z$ are the digits of the number. Then we seek solutions to

$$\underbrace{100x + 10y + z}_{n} + \underbrace{x+y+z}_{n's \; digits} = 313$$

Thus, simplifying, we seek integer solutions to

$$101 x + 11 y + 2 z = 313$$

I am stuck now as to how to solve this.

Thanks to all in advance.

Best Answer

The greatest possible sum of digits for a positive integer less than $313$ is $20$ (from $299$) so the minimum value you need to test is $293$. The sum of digits in this range is at least $3$ ($300$) and is at least $4$ for numbers other than $300$ so the greatest number you need to test is $309$

Either you are less than $300$ when, with units digit $a$ you have $290+2a+11=313$ and $a=6$, or greater than $300$ when $300+2a+3=313$, and $a=5$.