Let S ( n ) be the sum of digits of a positive integer n (when written in base 10).
If S ( n ) = 4 , find the maximum value of S ( n 4 ) .
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Can 130 be achieved? If so, how?
Log in to reply
Yes, I showed it can be achieved. Take n = 1 0 1 0 0 + 1 0 1 0 1 + 1 0 1 0 2 + 1 0 1 0 3 . The 1 0 p + q + r + s are far enough so that the coefficients don't interact and so don't cause any carry. You can also verify this using computer, if you want.
Log in to reply
n = 1000010011 - works too.
Log in to reply
@Siva Bathula – I think gives too many interactions.
Log in to reply
@Malcolm Rich – I didn't understand. What did you mean?
Log in to reply
@Siva Bathula – Setting n=1000010011, gives S (n^4) = 112 if I have done my sums right.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
|
Hey Ivan! Great solution! I'm really interested in learning number theory myself but am not sure how to proceed. Any suggestions??
Log in to reply
Read up on modular arithmetic and Euler's theorem would be one place to start.
Quite a long solution. Does it prove that all of the digits in 'n' have to be 0's and 1's?
Log in to reply
It is long because I tend to be too detailed. The basic idea is that you want to minimize the number of carries, then you notice that carries come from multinomial coefficients and as long as you can separate coefficients from each other, you won't get extra carries. Yes, all digits must be 0s and 1s, otherwise some coefficients will overlap and make more carries. (In particular, if n = 2 ⋅ 1 0 a + 1 0 b + 1 0 c , the coefficient of 1 0 4 a in n 4 is now 2 4 = 1 6 , so that's a carry.)
What does "when written in decimal" mean?
Log in to reply
There are many different number bases . The most common base is base 10, or decimal, which we often use. Computers often work in base 2 (binary).
Log in to reply
So, "when written in decimal" means witten in base 10?
My solution was essentially the same as Ivan's, but I try to keep the argument more informal/intuitive, less symbolic/rigorous.
We can think of the number n as being built by adding "ones". For instance, we could write 3 0 1 0 = 1 ⋅ 1 0 3 + 1 ⋅ 1 0 3 + 1 ⋅ 1 0 3 + 1 ⋅ 1 0 1 ; because S ( n ) = 4 , there must be four of these terms. In other words, n = 1 0 a 1 + 1 0 a 2 + 1 0 a 3 + 1 0 a 4 , with the a i possibly different, possibly the same. Taking the fourth power produces n 4 = 1 0 a i + a j + a k + a ℓ + ⋯ where ( i , j , k , ℓ ) = ( 1 , 1 , 1 , 1 ) ; ( 1 , 1 , 1 , 2 ) ; ( 1 , 1 , 1 , 3 ) ; … ( 4 , 4 , 4 , 3 ) ; ( 4 , 4 , 4 , 4 ) runs through all 256 possible ordered 4-tuples of indices 1,2,3,4.
In principle, each of these 256 terms contributes one to the sum of digits-- unless ten or more terms utilize the same power of 10. By way of illustration, S ( 8 × 1 0 5 ) = S ( 8 0 0 0 0 ) = 8 , but S ( 1 3 × 1 0 5 ) = S ( 1 3 0 0 0 0 ) = 4 rather than 1 3 . Each time a digit "overflows" because it is used ten or more times, the digit sum decreases by nine... Therefore, in order to maximize S ( n 4 ) we wish to minimize this overflow. This can be accomplished by choosing the power a i of very different magnitudes. For instance, n = 1 0 0 + 1 0 2 + 1 0 1 0 + 1 0 5 0 = 1 0 … 0 1 0 0 0 0 0 0 0 1 0 1 works well, because each possible value of a i + a j + a k + a ℓ corresponds to a unique choice of ( i , j , k , ℓ ) up to permutation.
That inevitable "up to permutation" is precisely why we cannot make S ( n 4 ) equal to 256. Out of our 256 terms 1 0 a i + a j + a k + a ℓ there will always be several equal to each other. We investigate by splitting out all possibilities. In the following, p , q , r , s stand for four different indices chosen from { 1 , 2 , 3 , 4 } .
Thus the digit sum will be, in the ideal case of no further overlap/overflow, S ( n 4 ) = 4 × 1 + 1 2 × 4 + 6 × 6 + 1 2 × 3 + 1 × 6 = 1 3 0 . (Note in contrast that without overflow, we would have 4 × 1 + 1 2 × 4 + 6 × 6 + 1 2 × 1 2 + 1 × 2 4 = 2 5 6 . )
With the concrete values mentioned above, we have as explicit example n = 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 1 ; n 4 = 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4 0 0 0 0 0 0 0 4 0 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 0 0 0 0 0 0 1 2 1 2 0 0 0 0 0 6 1 2 0 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4 0 0 0 0 0 0 1 2 1 2 0 0 0 0 1 2 2 4 1 2 0 0 0 4 1 2 1 2 0 4 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 4 0 4 0 0 0 0 0 6 1 2 0 6 0 0 0 4 1 2 1 2 0 4 0 1 0 4 0 6 0 4 0 1 .
Wait, why did you say that your solution is "less symbolic/rigorous"? Is there a certain gap in your solution? Because I don't know where the "hand-waving argument" part comes in.
Another superb solution by the way!
A further challenge: What is the smallest value of n form which S ( n ) = 4 and S ( n 4 ) = 1 3 0 ?
Log in to reply
n=10000100110
Log in to reply
Certainly not; since S ( 1 0 n ) = S ( n ) and S ( ( 1 0 n ) 4 ) = S ( n 4 ) , it follows that 1 0 0 0 0 1 0 0 1 1 results in the same digit sum as the number you propose. How do we know there is no smaller solution?
Log in to reply
@Arjen Vreugdenhil – You were very close, thought. The smallest solution is n = 1 0 0 0 0 1 0 0 1 1 . I found it as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
|
with output:
1 2 3 4 5 6 7 8 9 10 11 |
|
The last line shows that the optimum indeed has S ( n 4 ) = 1 3 0 , and the smallest value for which this happens is n = 1 0 9 + 1 0 4 + 1 0 1 + 1 0 0 = 1 0 0 0 0 1 0 0 1 1 with fourth power 1 0 0 0 0 4 0 0 4 4 6 0 1 3 2 4 7 3 9 2 2 4 5 6 9 3 9 6 6 5 3 2 5 4 6 4 1 .
if n=100....010...0100.....01 , wouldnt that make n^4 has 256 1s and alot of 0s?
To give an example, consider n=a+b+c+d, where a,b,c,d are all of the form 10^x. This is identical to your choice of n.
The expansion n^4 will include a term 24abcd but S (24abcd)=6 rather than 24. So however we arrange the 1's and 0's we can't avoid this loss of value in S(n^4).
Sorry, what's your point?
No it would not. For example, if you look at even 1 0 0 0 1 2 = 1 0 0 0 2 0 0 0 1 . You see how the 1's will interplay with each other: ( 1 0 0 0 0 + 1 ) ( 1 0 0 0 0 + 1 ) = 1 0 0 0 0 0 0 0 0 + 1 0 0 0 0 + 1 0 0 0 0 + 1 .
Thus, the problem requires us to account for the overlap, and figure out how to minimize the effect.
As I explained in my solution, some of the resulting products (the 1 0 p + q + r + s in my solution) must necessarily be equal even though they are generated from different combinations. As a simple example, ( 1 0 2 + 1 0 0 ) 2 = 1 0 4 + 1 0 2 + 1 0 2 + 1 0 0 ; we have two 1 0 2 , generated in two ways: a) picking 1 0 2 from the first factor and 1 0 0 from the second factor, and b) picking 1 0 0 from the first factor and 1 0 2 from the second factor. Thus we can already see that not all digits are going to be 1; the non-1 digits correspond to when we have several equal products.
When we consider n 4 , there are so many equal products that we have a carry from there. As I explained, factors in the form 1 0 2 p + q + r can be generated in 12 ways, so on the digit with place value 1 0 2 p + q + r , we have a "12". But clearly this is absurd; we instead have a carry to the higher digit, making a "2" on 1 0 2 p + q + r and a "1" on 1 0 2 p + q + r + 1 . We can see that this causes the sum of digits to decrease by 9, because instead of contributing 12 to the sum, this only contributes 1 + 2 = 3 to the sum.
Problem Loading...
Note Loading...
Set Loading...
First, we will make an observation. Suppose a , b are positive integers. Then S ( a + b ) can be computed from S ( a ) , S ( b ) , and the number of carries in a + b . Indeed, if there is no carry, then it's easy to see that S ( a + b ) = S ( a ) + S ( b ) . However, each carry will cause S ( a + b ) to decrease by 9; that's how much is lost by subtracting 10 from a "digit" and adding 1 to the next more significant digit. Thus if S ( a ) , S ( b ) are fixed and we want to maximize S ( a + b ) , we need to minimize the number of carries in a + b .
If we want to make this formal, let N be large enough; let a = ∑ n = 0 N a n 1 0 n , and similarly b = ∑ n = 0 N b n 1 0 n and c = a + b = ∑ n = 0 N c n 1 0 n , where 0 ≤ a n , b n , c n ≤ 9 . (By picking N large enough we can always do this. Some of the high-index digits may be zero, equivalent to padding zeroes to the left of the numbers.) Let d n indicate whether there is a carry when adding a n + b n ; formally, d 0 = 0 (no carry on rightmost column), and for 1 ≤ n ≤ N , d n = 1 if and only if a n − 1 + b n − 1 + d n − 1 ≥ 1 0 (which indicates there is a carry). If we're doing columnar addition like this , a n , b n , c n , d n represents the first addend row, the second addend row, the result row, and the carry row, respectively.
Now, S ( a ) = ∑ a n , S ( b ) = ∑ b n , S ( a + b ) = ∑ c n . But c n is defined as follows; if a n − 1 + b n − 1 + d n − 1 < 1 0 , then c n = a n − 1 + b n − 1 + d n − 1 , otherwise c n = a n − 1 + b n − 1 + d n − 1 − 1 0 . But this is coded in the definition of d n ; if a n − 1 + b n − 1 + d n − 1 < 1 0 , then d n = 0 , else d n = 1 . Thus we can write c n = a n − 1 + b n − 1 + d n − 1 − 1 0 d n . So S ( a + b ) = ∑ ( a n − 1 + b n − 1 + d n − 1 − 1 0 d n ) = ∑ a n + ∑ b n − 9 ∑ d n , showing that each carry reduces S ( a + b ) by 9.
Now to the problem. Since S ( n ) = 4 , we can represent n = 1 0 a + 1 0 b + 1 0 c + 1 0 d for nonnegative integers a , b , c , d ; we may assume a ≤ b ≤ c ≤ d . Then
n 4 = p , q , r , s ∈ { a , b , c , d } ∑ 1 0 p + q + r + s
Grouping like terms, we have
n 4 = p , q , r , s ∑ c p , q , r , s ⋅ 1 0 p + q + r + s
where p , q , r , s ∈ { a , b , c , d } , p ≤ q ≤ r ≤ s , and c p , q , r , s is a coefficient depending on p , q , r , s to be determined later.
Here we can already see that n 4 is the sum of several terms, more precisely c p , q , r , s ⋅ 1 0 p + q + r + s among all possible p , q , r , s . Each individual term has a fixed sum of digits, namely S ( c p , q , r , s ) (which, since it depends only on p , q , r , s , is fixed when p , q , r , s are fixed; note that 1 0 p + q + r + s just pads zeroes to the right and don't contribute to the sum of digits). Thus to maximize S ( n 4 ) , by the above observation, we want to make as few carries as possible. As it turns out, we can pick a , b , c , d to make sure none of these terms are even remotely close to interact, which means S ( n 4 ) is just the sum of S ( c p , q , r , s ) .
First, we need to figure out what is c p , q , r , s . This is actually easy; if we fix p , q , r , s , we're counting the coefficient of 1 0 p + q + r + s . This is given by multinomial theorem. For example, if p = a , q = a , r = b , s = c , then we're finding the coefficient of 1 0 2 a + b + c , which is given by the multinomial coefficient ( 2 , 1 , 1 4 ) = 2 ! 1 ! 1 ! 4 ! = 1 2 . We can see that the largest c p , q , r , s is achieved when p = a , q = b , r = c , s = d , giving a coefficient of 24.
So, in fact, if we can make sure that p + q + r + s differs by at least 2 for different choices of p , q , r , s , we can make sure that the terms c p , q , r , s ⋅ 1 0 p + q + r + s don't interact and thus don't give any carry when added together. This can be achieved by, for example, picking a = 1 0 0 , b = 1 0 1 , c = 1 0 2 , d = 1 0 3 ; the proof is left to the reader.
Now, we know that S ( n 4 ) = ∑ S ( c p , q , r , s ) . We just need to find the values of c p , q , r , s and find the sum of the digits of each. This is where it gets messy, but at least we can simplify this into just five cases:
Thus, we can see that in the fourth case above, we lose 9 due to carry ( c p , q , r , s = 1 2 but S ( c p , q , r , s ) = 3 ), and there are 12 coefficients that fall to the fourth case, so in total we lose 108 due to carry. The last case loses 18 more due to carry. In total, we lose 126 due to carries in the coefficients. This is the best we can do.
But we can easily compute ∑ c p , q , r , s . This is simply 4 4 = 2 5 6 : we pick a term from 1 0 a + 1 0 b + 1 0 c + 1 0 d in each factor of n 4 = n ⋅ n ⋅ n ⋅ n . There are 4 ways to pick a term, and 4 terms in total, so we have 4 4 = 2 5 6 ways. Each way of picking the terms contributes exactly 1 to ∑ c p , q , r , s , by definition of them being coefficients. So ∑ c p , q , r , s = 2 5 6 . Since we lose 126 due to carry, we have ∑ S ( c p , q , r , s ) = 1 3 0 , so max S ( n 4 ) = 1 3 0 .
A variant of this problem, giving S ( n ) = 5 and asking for S ( n 5 ) , was given for the city qualifiers for Indonesian National Science Olympiad in Mathematics.
I simplified the problem so that we only have 5 cases. If the sum is 5, we have 7 cases to go through. (5 is also the number of partitions of 4, and 7 is the number of partitions of 5; this is not a coincidence.)