Sum of digits

Let S ( n ) S(n) be the sum of digits of a positive integer n n (when written in base 10).

If S ( n ) = 4 S(n) = 4 , find the maximum value of S ( n 4 ) S\big(n^4\big) .


The answer is 130.

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.

3 solutions

Ivan Koswara
Mar 30, 2017

First, we will make an observation. Suppose a , b a, b are positive integers. Then S ( a + b ) S(a+b) can be computed from S ( a ) , S ( b ) S(a), S(b) , and the number of carries in a + b a+b . Indeed, if there is no carry, then it's easy to see that S ( a + b ) = S ( a ) + S ( b ) S(a+b) = S(a) + S(b) . However, each carry will cause S ( a + b ) 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 ) S(a), S(b) are fixed and we want to maximize S ( a + b ) S(a+b) , we need to minimize the number of carries in a + b a+b .

If we want to make this formal, let N N be large enough; let a = n = 0 N a n 1 0 n a = \sum_{n=0}^N a_n 10^n , and similarly b = n = 0 N b n 1 0 n b = \sum_{n=0}^N b_n 10^n and c = a + b = n = 0 N c n 1 0 n c = a+b = \sum_{n=0}^N c_n 10^n , where 0 a n , b n , c n 9 0 \le a_n, b_n, c_n \le 9 . (By picking N 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 d_n indicate whether there is a carry when adding a n + b n a_n + b_n ; formally, d 0 = 0 d_0 = 0 (no carry on rightmost column), and for 1 n N 1 \le n \le N , d n = 1 d_n = 1 if and only if a n 1 + b n 1 + d n 1 10 a_{n-1} + b_{n-1} + d_{n-1} \ge 10 (which indicates there is a carry). If we're doing columnar addition like this , a n , b n , c n , d n 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 S(a) = \sum a_n, S(b) = \sum b_n, S(a+b) = \sum c_n . But c n c_n is defined as follows; if a n 1 + b n 1 + d n 1 < 10 a_{n-1} + b_{n-1} + d_{n-1} < 10 , then c n = a n 1 + b n 1 + d n 1 c_n = a_{n-1} + b_{n-1} + d_{n-1} , otherwise c n = a n 1 + b n 1 + d n 1 10 c_n = a_{n-1} + b_{n-1} + d_{n-1} - 10 . But this is coded in the definition of d n d_n ; if a n 1 + b n 1 + d n 1 < 10 a_{n-1} + b_{n-1} + d_{n-1} < 10 , then d n = 0 d_n = 0 , else d n = 1 d_n = 1 . Thus we can write c n = a n 1 + b n 1 + d n 1 10 d n c_n = a_{n-1} + b_{n-1} + d_{n-1} - 10 d_n . So S ( a + b ) = ( a n 1 + b n 1 + d n 1 10 d n ) = a n + b n 9 d n S(a+b) = \sum (a_{n-1} + b_{n-1} + d_{n-1} - 10 d_n) = \sum a_n + \sum b_n - 9 \sum d_n , showing that each carry reduces S ( a + b ) S(a+b) by 9.


Now to the problem. Since S ( n ) = 4 S(n) = 4 , we can represent n = 1 0 a + 1 0 b + 1 0 c + 1 0 d n = 10^a + 10^b + 10^c + 10^d for nonnegative integers a , b , c , d a, b, c, d ; we may assume a b c d a \le b \le c \le d . Then

n 4 = p , q , r , s { a , b , c , d } 1 0 p + q + r + s \displaystyle n^4 = \sum_{p,q,r,s \in \{a,b,c,d\}} 10^{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 \displaystyle n^4 = \sum_{p,q,r,s} c_{p,q,r,s} \cdot 10^{p+q+r+s}

where p , q , r , s { a , b , c , d } p,q,r,s \in \{a,b,c,d\} , p q r s p \le q \le r \le s , and c p , q , r , s c_{p,q,r,s} is a coefficient depending on p , q , r , s p,q,r,s to be determined later.

Here we can already see that n 4 n^4 is the sum of several terms, more precisely c p , q , r , s 1 0 p + q + r + s c_{p,q,r,s} \cdot 10^{p+q+r+s} among all possible p , q , r , s p,q,r,s . Each individual term has a fixed sum of digits, namely S ( c p , q , r , s ) S(c_{p,q,r,s}) (which, since it depends only on p , q , r , s p,q,r,s , is fixed when p , q , r , s p,q,r,s are fixed; note that 1 0 p + q + r + s 10^{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 ) 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 a,b,c,d to make sure none of these terms are even remotely close to interact, which means S ( n 4 ) S(n^4) is just the sum of S ( c p , q , r , s ) S(c_{p,q,r,s}) .

First, we need to figure out what is c p , q , r , s c_{p,q,r,s} . This is actually easy; if we fix p , q , r , s p,q,r,s , we're counting the coefficient of 1 0 p + q + r + s 10^{p+q+r+s} . This is given by multinomial theorem. For example, if p = a , q = a , r = b , s = c p = a, q = a, r = b, s = c , then we're finding the coefficient of 1 0 2 a + b + c 10^{2a+b+c} , which is given by the multinomial coefficient ( 4 2 , 1 , 1 ) = 4 ! 2 ! 1 ! 1 ! = 12 \binom{4}{2,1,1} = \frac{4!}{2! 1! 1!} = 12 . We can see that the largest c p , q , r , s c_{p,q,r,s} is achieved when p = a , q = b , r = c , s = d 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 p+q+r+s differs by at least 2 for different choices of p , q , r , s p,q,r,s , we can make sure that the terms c p , q , r , s 1 0 p + q + r + s c_{p,q,r,s} \cdot 10^{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 a = 10^0, b = 10^1, c = 10^2, d = 10^3 ; the proof is left to the reader.

Now, we know that S ( n 4 ) = S ( c p , q , r , s ) S(n^4) = \sum S(c_{p,q,r,s}) . We just need to find the values of c p , q , r , s 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:

  • If all of p , q , r , s p,q,r,s are the same, the coefficient is ( 4 4 ) = 1 \binom{4}{4} = 1 . There are 4 choices of p , q , r , s p,q,r,s that lead to this case (all of them equal to one of a , b , c , d a, b, c, d ).
  • If three of p , q , r , s p,q,r,s are the same and the other is different, the coefficient is ( 4 3 , 1 ) = 4 \binom{4}{3,1} = 4 . There are 12 such choices: 4 ways to pick the triple, and 3 ways to pick the singleton.
  • If they come in two pairs, the coefficient is ( 4 2 , 2 ) = 6 \binom{4}{2,2} = 6 , and there are 6 such choices. (4 ways to pick the first pair, 3 ways to pick the second pair, divided by 2 for being able to switch them around.)
  • If two are equal and the remaining two are different, the coefficient is ( 4 2 , 1 , 1 ) = 12 \binom{4}{2,1,1} = 12 , and there are 12 such choices. (4 ways to pick the pair, 3 ways to pick the unchosen number.)
  • If all are different, the coefficient is ( 4 1 , 1 , 1 , 1 ) = 24 \binom{4}{1,1,1,1} = 24 , and there is 1 such choice.

Thus, we can see that in the fourth case above, we lose 9 due to carry ( c p , q , r , s = 12 c_{p,q,r,s} = 12 but S ( c p , q , r , s ) = 3 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 \sum c_{p,q,r,s} . This is simply 4 4 = 256 4^4 = 256 : we pick a term from 1 0 a + 1 0 b + 1 0 c + 1 0 d 10^a + 10^b + 10^c + 10^d in each factor of n 4 = n n n n n^4 = n \cdot n \cdot n \cdot n . There are 4 ways to pick a term, and 4 terms in total, so we have 4 4 = 256 4^4 = 256 ways. Each way of picking the terms contributes exactly 1 to c p , q , r , s \sum c_{p,q,r,s} , by definition of them being coefficients. So c p , q , r , s = 256 \sum c_{p,q,r,s} = 256 . Since we lose 126 due to carry, we have S ( c p , q , r , s ) = 130 \sum S(c_{p,q,r,s}) = 130 , so max S ( n 4 ) = 130 \max S(n^4) = \boxed{130} .


A variant of this problem, giving S ( n ) = 5 S(n) = 5 and asking for S ( n 5 ) S\big(n^5\big) , 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.)

Can 130 be achieved? If so, how?

Calvin Lin Staff - 4 years, 2 months ago

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 n = 10^{10^0} + 10^{10^1} + 10^{10^2} + 10^{10^3} . The 1 0 p + q + r + s 10^{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.

Ivan Koswara - 4 years, 2 months ago

Log in to reply

n = 1000010011 - works too.

Siva Bathula - 4 years, 2 months ago

Log in to reply

@Siva Bathula I think gives too many interactions.

Malcolm Rich - 4 years, 2 months ago

Log in to reply

@Malcolm Rich I didn't understand. What did you mean?

Siva Bathula - 4 years, 2 months ago

Log in to reply

@Siva Bathula Setting n=1000010011, gives S (n^4) = 112 if I have done my sums right.

Malcolm Rich - 4 years, 2 months ago

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
def to_base_5(n):
    s = ""
    while n:
        s = str(n % 5) + s
        n /= 5
    return s

def digitsum(x):
    total=0
    for letter in str(x):
        total+=int(letter)
    return total

max_ = 0
for i in range(1,100000000):
    if digitsum(to_base_5(i)) == 4 and digitsum(str(int(to_base_5(i))**4)) > max_:
        print to_base_5(i), int(to_base_5(i))**4, digitsum(str(int(to_base_5(i))**4))
        max_ = digitsum(str(int(to_base_5(i))**4))

 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
4 256 13
13 28561 22
103 112550881 31
112 157351936 40
202 1664966416 49
1012 1048870932736 58
10012 10048086469140736 67
11011 14699651904578641 85
110011 146468572785185654641 103
1010011 1040649343984597977254641 121
1000010011 1000040044601324739224569396653254641 130
........
10100000000010010000 10406040100041253252040061328473206040521321240410040060040010000000000000000 130
10100000000100000001 10406040100412120404127324600122452400613272100012124000040460000000400000001 130
10100000000100000010 10406040100412120441218160601224160461218120101212040040406000000400000010000 130
10100000000100000100 10406040100412120812126520612241246520721200221200440400600000400000100000000 130
10100000000100010000 10406040100412161612046121824181246412121212140440006000400010000000000000000 130
10100000000100100000 10406040100412532520406132847320640521321240500400600400100000000000000000000 130
10100000001000000001 10406040104121204004733264001264520000734260000125200000046400000004000000001 130
10100000001000000100 10406040104121204412732460122452406132721001212400040460000004000000100000000 130
10100000010000000001 10406040141212040065327204052641200022732060005212000000640400000040000000001 130
10100000010000000100 10406040141212040473326401264520007342600012520000046400000040000000100000000 130
10100000010000010000 10406040141212081273246122452461327210121240040460000040000010000000000000000 130
10100000010000100000 10406040141212452181607224166521812022120440406000040000100000000000000000000 130
10100000010001000000 10406040141216161265218241852472121222044400600040001000000000000000000000000 130
10100000100000000001 10406040512120406124721244522412101212612064012120000060040400000400000000001 130
..........
101000010000000010000 104060442212046161812456241211218120641212000060404000040000000010000000000000000 130
101000010000000100000 104060442212046532720926412022732060521200006404000040000000100000000000000000000 130
101000010000010000000 104060442212087332652645207342601252000464000040000010000000000000000000000000000 130
101000010001000000000 104060442216167325824585327222124404600040001000000000000000000000000000000000000 130
........

Michael Fitzgerald - 3 years, 1 month ago

Hey Ivan! Great solution! I'm really interested in learning number theory myself but am not sure how to proceed. Any suggestions??

Chirag Singapore - 4 years, 2 months ago

Log in to reply

Read up on modular arithmetic and Euler's theorem would be one place to start.

Malcolm Rich - 4 years, 2 months ago

Quite a long solution. Does it prove that all of the digits in 'n' have to be 0's and 1's?

Malcolm Rich - 4 years, 2 months ago

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 n = 2 \cdot 10^a + 10^b + 10^c , the coefficient of 1 0 4 a 10^{4a} in n 4 n^4 is now 2 4 = 16 2^4 = 16 , so that's a carry.)

Ivan Koswara - 4 years, 2 months ago

What does "when written in decimal" mean?

Fidel Simanjuntak - 4 years, 1 month ago

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).

Ivan Koswara - 4 years, 1 month ago

Log in to reply

So, "when written in decimal" means witten in base 10?

Fidel Simanjuntak - 4 years, 1 month ago

Log in to reply

@Fidel Simanjuntak Yes, written in base 10.

Ivan Koswara - 4 years, 1 month ago
Arjen Vreugdenhil
Apr 13, 2017

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 n as being built by adding "ones". For instance, we could write 3010 = 1 1 0 3 + 1 1 0 3 + 1 1 0 3 + 1 1 0 1 ; 3010 = 1\cdot 10^3 + 1\cdot 10^3 + 1\cdot 10^3 + 1\cdot 10^1; because S ( n ) = 4 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 , n = 10^{a_1} + 10^{a_2} + 10^{a_3} + 10^{a_4}, with the a i a_i possibly different, possibly the same. Taking the fourth power produces n 4 = 1 0 a i + a j + a k + a + n^4 = 10^{a_i+a_j+a_k+a_\ell} + \cdots where ( i , j , k , ) = ( 1 , 1 , 1 , 1 ) ; ( 1 , 1 , 1 , 2 ) ; ( 1 , 1 , 1 , 3 ) ; ( 4 , 4 , 4 , 3 ) ; ( 4 , 4 , 4 , 4 ) (i,j,k,\ell) = (1,1,1,1);\ (1,1,1,2);\ (1,1,1,3);\ \dots\ (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 ( 80000 ) = 8 , but S ( 13 × 1 0 5 ) = S ( 130000 ) = 4 rather than 13. S(8 \times 10^5) = S(80000) = 8,\ \ \ \text{but}\ \ \ S(13\times 10^5) = S(130000) = 4\ \text{rather than}\ 13. 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 ) S(n^4) we wish to minimize this overflow. This can be accomplished by choosing the power a i a_i of very different magnitudes. For instance, n = 1 0 0 + 1 0 2 + 1 0 10 + 1 0 50 = 10 010000000101 n = 10^0 + 10^2 + 10^{10} + 10^{50} = 10\dots 010000000101 works well, because each possible value of a i + a j + a k + a a_i+a_j+a_k+a_\ell corresponds to a unique choice of ( i , j , k , ) (i,j,k,\ell) up to permutation.

That inevitable "up to permutation" is precisely why we cannot make S ( n 4 ) S(n^4) equal to 256. Out of our 256 terms 1 0 a i + a j + a k + a 10^{a_i+a_j+a_k+a_\ell} there will always be several equal to each other. We investigate by splitting out all possibilities. In the following, p , q , r , s p,q,r,s stand for four different indices chosen from { 1 , 2 , 3 , 4 } \{1,2,3,4\} .

  • ( i , j , k , ) = ( p , p , p , p ) (i,j,k,\ell) = (p,p,p,p) . There are four possible values p = 1 , , 4 p = 1, \dots, 4 , and for each only one possible permutations. In the ideal case, this contributes four times 1 to the digit sum.
  • ( i , j , k , ) = ( p , p , p , q ) (i,j,k,\ell) = (p,p,p,q) etc. There are twelve possible values for p , q p,q , and for each four possible permutations: ( p , p , p , q ) , ( p , p , q , p ) , ( p , q , p , p ) , ( q , p , p , p ) (p,p,p,q), (p,p,q,p), (p,q,p,p), (q,p,p,p) . Therefore we get twelve contributions of 4 to the digit sum.
  • ( i , j , k , ) = ( p , p , q , q ) (i,j,k,\ell) = (p,p,q,q) etc. There are six possible values for { p , q } \{p,q\} , and for each six possible permutations. Therefore we get six contributions of 6 to the digit sum.
  • ( i , j , k , ) = ( p , p , q , r ) (i,j,k,\ell) = (p,p,q,r) etc. There are twelve possible values for p , s p,s ( s s being the unused index), and for each twelve possible permutations. Thus there will be twelve contributions of 12 × 1 0 2 a p + a q + a r 12\times 10^{2a_p+a_q+a_r} to n 4 n^4 . There is "overflow"; instead of contributing 12 12 to the digit sum, this only contributes 3 3 to the digit sum, twelve times.
  • ( i , j , k , ) = ( p , q , r , s ) (i,j,k,\ell) = (p,q,r,s) etc. There is one possible choice { p , q , r , s } = { 1 , 2 , 3 , 4 } \{p,q,r,s\} = \{1,2,3,4\} but there are 24 permutations. Thus there is a contribution of 24 × 1 0 a 1 + a 2 + a 3 + a 4 24\times 10^{a_1+a_2+a_3+a_4} to n 4 n^4 . Again, there is "overflow"; instead of contributing 24 24 to the digit sum, we only contribute 6 6 .

Thus the digit sum will be, in the ideal case of no further overlap/overflow, S ( n 4 ) = 4 × 1 + 12 × 4 + 6 × 6 + 12 × 3 + 1 × 6 = 130 . S(n^4) = 4\times 1 + 12\times 4 + 6\times 6 + 12\times 3 + 1\times 6 = \boxed{130}. (Note in contrast that without overflow, we would have 4 × 1 + 12 × 4 + 6 × 6 + 12 × 12 + 1 × 24 = 256. ) 4\times 1 + 12\times 4 + 6\times 6 + 12\times 12 + 1\times 24 = 256.)

With the concrete values mentioned above, we have as explicit example n = 1 0000000000 0000000000 0000000000 0000000001 0000000101 ; n = 1\,0000000000\,0000000000\,0000000000\,0000000001\,0000000101; n 4 = 1 0000000000 0000000000 0000000000 0000000004 0000000404 0000000000 0000000000 0000000006 0000001212 0000061206 0000000000 0000000004 0000001212 0000122412 0004121204 0000000001 0000000404 0000061206 0004121204 0104060401. n^4 = 1\,0000000000\,0000000000\,0000000000\,0000000004\,0000000404 \\ 0000000000\,0000000000\,0000000006\,0000001212\,0000061206 \\ 0000000000\,0000000004\,0000001212\,0000122412\,0004121204 \\ 0000000001\,0000000404\,0000061206\,0004121204\,0104060401.

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!

Pi Han Goh - 4 years, 1 month ago

A further challenge: What is the smallest value of n n form which S ( n ) = 4 S(n) = 4 and S ( n 4 ) = 130 S(n^4) = 130 ?

Arjen Vreugdenhil - 4 years, 1 month ago

Log in to reply

n=10000100110

Arvydas Karbonskis - 4 years, 1 month ago

Log in to reply

Certainly not; since S ( 10 n ) = S ( n ) S(10n) = S(n) and S ( ( 10 n ) 4 ) = S ( n 4 ) S((10n)^4) = S(n^4) , it follows that 1000010011 1000010011 results in the same digit sum as the number you propose. How do we know there is no smaller solution?

Arjen Vreugdenhil - 4 years, 1 month ago

Log in to reply

@Arjen Vreugdenhil You were very close, thought. The smallest solution is n = 1000010011 n = 1000010011 . 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
int ex[] = new int[4];
int dig[] = new int[401];
int bestS = -1;

for (ex[3] = 0; ex[3] < 100; ex[3]++)
    for (ex[2] = 0; ex[2] <= ex[3]; ex[2]++)
        for (ex[1] = 0; ex[1] <= ex[2]; ex[1]++) {

    ex[0] = 0;
    for (int i = 0; i < 400; i++) dig[i] = 0;

    for (int a = 0; a < 4; a++)
        for (int b = 0; b < 4; b++)
            for (int c = 0; c < 4; c++)
                for (int d = 0; d < 4; d++)
                    dig[ex[a]+ex[b]+ex[c]+ex[d]]++;

    int S = 0;
    for (int i = 0; i < 400; i++) {
        while (dig[i] >= 10) { dig[i]-=10; dig[i+1]++; }
        S += dig[i];
    }

    if (S > bestS || bestS < 0) {
        bestS = S;
        System.out.println(""+S+": "+ex[3]+","+ex[2]+","+ex[1]+","+ex[0]);
    }
}

with output:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
13: 0,0,0,0
22: 1,0,0,0
31: 2,0,0,0
40: 2,1,0,0
49: 2,2,0,0
58: 3,1,0,0
67: 4,1,0,0
85: 4,3,1,0
103: 5,4,1,0
121: 6,4,1,0
130: 9,4,1,0

The last line shows that the optimum indeed has S ( n 4 ) = 130 S(n^4) = 130 , and the smallest value for which this happens is n = 1 0 9 + 1 0 4 + 1 0 1 + 1 0 0 = 1000010011 n = 10^9 + 10^4 + 10^1 + 10^0 = 1000010011 with fourth power 1 000 040 044 601 324 739 224 569 396 653 254 641. 1\,000\,040\,044\,601\,324\,739\,224\,569\,396\,653\,254\,641.

Arjen Vreugdenhil - 4 years, 1 month ago
Eric Louis
Apr 12, 2017

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).

Malcolm Rich - 4 years, 2 months ago

Sorry, what's your point?

Agnishom Chattopadhyay - 4 years, 2 months ago

No it would not. For example, if you look at even 1000 1 2 = 100020001 10001^2 = 100020001 . You see how the 1's will interplay with each other: ( 10000 + 1 ) ( 10000 + 1 ) = 100000000 + 10000 + 10000 + 1 (10000+1)(10000+1) = 100000000 + 10000 + 10000 + 1 .

Thus, the problem requires us to account for the overlap, and figure out how to minimize the effect.

Calvin Lin Staff - 4 years, 2 months ago

As I explained in my solution, some of the resulting products (the 1 0 p + q + r + s 10^{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 (10^2 + 10^0)^2 = 10^4 + 10^2 + 10^2 + 10^0 ; we have two 1 0 2 10^2 , generated in two ways: a) picking 1 0 2 10^2 from the first factor and 1 0 0 10^0 from the second factor, and b) picking 1 0 0 10^0 from the first factor and 1 0 2 10^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 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 10^{2p+q+r} can be generated in 12 ways, so on the digit with place value 1 0 2 p + q + r 10^{2p+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 10^{2p+q+r} and a "1" on 1 0 2 p + q + r + 1 10^{2p+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 1+2 = 3 to the sum.

Ivan Koswara - 4 years, 2 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...