Let $S(n)$ denote the sum of digits of a natural number $n$. Find all $n$ for which $n+S(n)=2004$.
Problem
Source:
Tags: number theory
12.04.2021 22:47
this reminds me of 2007 AMC 10A Problem 25.
12.04.2021 22:58
$n$ is $4$ digits. $n\ge 2004-36=1968$ now we bash def digitsum(x): ans = 0 while x>0: ans += x % 10 x //= 10 return ansfor i in range(1968, 2004): if i + digitsum(i) == 2004: print(i)def digitsum(x): ans = 0 while x>0: ans += x % 10 x //= 10 return ans for i in range(1968, 2004): if i + digitsum(i) == 2004: print(i)RunResetPop Out / JK JK we use the fact that s(n) is n mod 9 so n is 3 mod 9. our only possiblities are 1974, 1983, 1992, 2001 clearly only 1983 and 2001 work. qed
12.04.2021 23:01
jasperE3 wrote: Let $S(n)$ denote the sum of digits of a natural number $n$. Find all $n$ for which $n+S(n)=2004$. Where do you find all these problems?
12.04.2021 23:03
anyone have a solution?
13.04.2021 00:10
math31415926535 wrote: anyone have a solution? Bashing is the most obvious solution, although I've seen an Alcumus problem that looks eerily similar to this and has a pretty clever solution.
13.04.2021 00:22
math31415926535 wrote: anyone have a solution? my solution RedFireTruck wrote: $n$ is $4$ digits. $n\ge 2004-36=1968$ now we bash def digitsum(x): ans = 0 while x>0: ans += x % 10 x //= 10 return ansfor i in range(1968, 2004): if i + digitsum(i) == 2004: print(i)def digitsum(x): ans = 0 while x>0: ans += x % 10 x //= 10 return ans for i in range(1968, 2004): if i + digitsum(i) == 2004: print(i)RunResetPop Out / JK JK we use the fact that s(n) is n mod 9 so n is 3 mod 9. our only possiblities are 1974, 1983, 1992, 2001 clearly only 1983 and 2001 work. qed
15.04.2021 11:26
sol
15.04.2021 15:05
inoxb198 wrote: sol
basically just my solution but shorter...