One More than Triple 8s

Find the sum of the digits of the 889th smallest positive integer whose square ends in 889.


The answer is 14.

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.

5 solutions

Otto Bretscher
Apr 11, 2015

We can streamline Steven's excellent approach a bit. My solution will be based on the observation that x 2 x^2 ends in ... 889 if and only if x 2 889 x^2-889 is divisible by both 125 and 8. Now x 2 889 x^2-889 is divisible by 8 for all odd numbers x x , since x 2 1 889 ( m o d 8 ) x^2\equiv1\equiv889 (\mod 8) for odd x x . The real issue is the divisibility by 125. Let's find the solutions of x 2 889 14 ( m o d 125 ) x^2\equiv889\equiv14 (\mod 125) . Working our way up, we see that the solutions of x 2 889 4 ( m o d 5 ) x^2\equiv889\equiv4 (\mod 5) are 2 and 5 2 = 3 5-2=3 , and the solutions of x 2 889 14 ( m o d 25 ) x^2\equiv889\equiv14 (\mod 25) are 8 and 25 8 = 17 25-8=17 ; we only need to check 2, 7, 12, 3 and 8 here. Finally, the solutions of x 2 889 14 ( m o d 125 ) x^2\equiv889\equiv14 (\mod 125) are 42 and 125 42 = 83 125-42=83 (again, we only need to check 5 candidates). Thus every interval [ 125 ( n 1 ) , 125 n ] [125(n-1), 125n] contains exactly two x x with x 2 889 14 ( m o d 125 ) x^2\equiv889\equiv14 (\mod 125) , an even and an odd number. (As Martin observes, these two numbers are 125 n 83 125n-83 and 125 n 42 125n-42 ). If such a number x x is odd, then x 2 x^2 will end in ...889, as we observed earlier. The 889th such number is 125 × 889 42 = 125 × 888 + 83 = 111083 125\times889-42=125\times888+83=111083 .

@Otto Bretscher , we really liked your comment, and have converted it into a solution. If you subscribe to this solution, you will receive notifications about future comments.

Brilliant Mathematics Staff - 6 years, 2 months ago

Just for the sake of curiosity, by extending Steven Yuan 's solution we obtain a formula for the n n 'th positive integer whose square ends in 889 889 . Let us call such a number an 889-number.

We have that { 50 i + 33 } i = 0 \left\{50i + 33\right\}_{i=0}^{\infty} is a sequence of numbers whose respective squares end in 89, and further that if i = 1 + 5 j i = 1 + 5j , the respective squares end in 889 889 . That is, for a non-negative integer j j , the square of s 1 ( j ) = 250 j + 83 s_1(j) = 250j + 83 ends in 889 889 .

Similarly for numbers { 10 i + 7 } i = 0 \left\{10i + 7\right\}_{i=0}^{\infty} , we conclude that for a non-negative integer j j , the square of s 2 ( j ) = 250 j + 167 s_2(j) = 250j + 167 ends in 889 889 .

Notice that s 1 ( j ) < s 2 ( j ) < s 1 ( j + 1 ) < s 2 ( j + 1 ) s_1(j) < s_2(j) < s_1(j+1) < s_2(j+1) for j 0 j \geq 0 . So to get the k k 'th 889-number, we compute s 1 ( k 1 2 ) s_1\left(\frac{k-1}{2}\right) if k k is odd; otherwise we compute s 2 ( k 2 1 ) s_2\left(\frac{k}{2} - 1\right) .

Hence, the n n 'th 889-number can be computed as N 889 ( n ) = { 125 n 42 if n is odd 125 n 83 if n is even N_{889}(n) = \begin{cases} 125n - 42 & \text{if } n \text{ is odd} \\ 125n - 83 & \text{if } n \text{ is even} \end{cases}

(Edit by me: Simplified formula by @Otto Bretscher )

Otto Bretscher mentions in a comment further below that we can express N N in a single line: N 889 ( n ) = 125 ( 2 n 1 ) 41 ( 1 ) n 2 N_{889}(n) = \frac{125(2 n - 1) - 41(-1)^n}{2}

@Martin Sergio H. Faester , we really liked your comment, and have converted it into a solution. If you subscribe to this solution, you will receive notifications about future comments.

Brilliant Mathematics Staff - 6 years, 2 months ago
Steven Yuan
Mar 17, 2015

I don't have time for a full solution yet, so here's a general outline:

Let a a be our desired integer. We know that a a must end with 3 3 or 7 7 . Thus, a a is of the form 10 n + 3 10n + 3 or 10 n + 7 10n + 7 , for some positive integer n n . So, we have two cases:

Case 1: The number is of the form 10 n + 3 10n + 3

Squaring and taking m o d 100 \! \mod \! 100 yields n 3 ( m o d 5 ) n \equiv 3 \pmod{5} , or n = 5 m + 3 n = 5m + 3 for some positive integer m m . Plug this back into our squared expression and taking m o d 1000 \! \mod \! 1000 yields m 1 ( m o d 10 ) m \equiv 1 \pmod{10} or m 6 ( m o d 10 ) m \equiv 6 \pmod{10} . Thus, n = 8 , 33 , 83 , n = 8, 33, 83, \cdots .

Case 2: The number is of the form 10 n + 7 10n + 7

Following the same steps as Case 1 yields n = 5 m + 1 n = 5m + 1 and m 3 ( m o d 10 ) m \equiv 3 \pmod{10} or 8 ( m o d 10 ) 8 \pmod{10} . Thus, n = 16 , 41 , 66 , n = 16, 41, 66, \cdots .

Our first few values for a a are

83 , 167 , 333 , 417 , 583 , 667 , 833 , 917 , . 83, 167, 333, 417, 583, 667, 833, 917, \cdots .

The rest of the integers in this sequence just append digits in front of the eight smallest solutions e.g. 72833 , 31415926917 72833, 31415926917 , and they repeat in chunks of eight. Since 889 1 ( m o d 8 ) 889 \equiv 1 \pmod{8} , a a will end in 083 083 . Since 889 8 = 111 \left \lfloor \frac{889}{8} \right \rfloor = 111 , the integers appended are 111 111 . Thus, a = 111083 a = 111083 , which has digit sum 14 \boxed{14} .

Just for the sake of curiosity, by extending Steven Yuan 's solution we obtain a formula for the n n 'th positive integer whose square ends in 889 889 . Let us call such a number an 889-number.

We have that { 50 i + 33 } i = 0 \left\{50i + 33\right\}_{i=0}^{\infty} is a sequence of numbers whose respective squares end in 89, and further that if i = 1 + 5 j i = 1 + 5j , the respective squares end in 889 889 . That is, for a non-negative integer j j , the square of s 1 ( j ) = 250 j + 83 s_1(j) = 250j + 83 ends in 889 889 .

Similarly for numbers { 10 i + 7 } i = 0 \left\{10i + 7\right\}_{i=0}^{\infty} , we conclude that for a non-negative integer j j , the square of s 2 ( j ) = 250 j + 167 s_2(j) = 250j + 167 ends in 889 889 .

Notice that s 1 ( j ) < s 2 ( j ) < s 1 ( j + 1 ) < s 2 ( j + 1 ) s_1(j) < s_2(j) < s_1(j+1) < s_2(j+1) for j 0 j \geq 0 . So to get the k k 'th 889-number, we compute s 1 ( k 1 2 ) s_1\left(\frac{k-1}{2}\right) if k k is odd; otherwise we compute s 2 ( k 2 1 ) s_2\left(\frac{k}{2} - 1\right) .

Hence, the n n 'th 889-number can be computed as N 889 ( n ) = { 125 n 42 if n is odd 125 n 83 if n is even N_{889}(n) = \begin{cases} 125n - 42 & \text{if } n \text{ is odd} \\ 125n - 83 & \text{if } n \text{ is even} \end{cases}

Martin Sergio H. Faester - 6 years, 2 months ago

Log in to reply

We can even write a single formula, N ( n ) = 125 ( 2 n 1 ) 41 ( 1 ) n 2 N(n)=\frac{125(2n-1)-41(-1)^n}{2}

Otto Bretscher - 6 years, 2 months ago

Your solution would be much clearer if you applied the Chinese Remainder Theorem directly, to explain why the numbers must be of the form that you stated.

Calvin Lin Staff - 6 years, 2 months ago
David Holcer
Mar 17, 2015
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
array=[]
enough=False
num=1
summ=0
while not enough:
    if str(num**2)[-3:]=='889':
        array.append(num)
    if len(array)==889:
        enough=True
    num+=1
for i in str(array[-1]):
    summ+=int(i)
print summ

Brock Brown
Mar 17, 2015

Python 2.7:

1
2
3
4
5
6
7
ends_with_889 = 0
n = 0
while ends_with_889 < 889:
    n += 1
    if str(n*n).endswith('889'):
        ends_with_889 += 1
print "Answer:", sum([int(c) for c in str(n)])

I did it little differently, though.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
>>> def win(n):
    A = []
    x = 1
    while len(A) != n:
        while ((x+1)**2%1000 != 889):
            x = x+1
        A.append(x+1)
        x = x+1
    return A[n-1]
>>> def sum_digits(n):
    N = str(n)
    S = 0
    for i in N:
        S = S + int(i)
    return S
>>> print sum_digits(win(889))

Kartik Sharma - 6 years, 2 months ago

Log in to reply

I always like to define functions so that I can use them in future also whenever possible and they look nicer as well.

Kartik Sharma - 6 years, 2 months ago

Yeah, this problem can be killed with a simple script, but the "real" solution requires just number theory. ¨ \ddot \smile

Steven Yuan - 6 years, 2 months ago

Log in to reply

Yeah, I know. :|

I usually pick the lame option and kill problems with scripts, but I definitely want to learn how to do it though. If you have some good resources on number theory I'd like to see them.

Brock Brown - 6 years, 2 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...