The Digits ABCABD

How many possible 6 digit numbers are there of the form N = a b c a b d N=\overline{abcabd} where a 0 , d 0 a \neq 0, d \neq 0 , d = c + 1 d = c + 1 and N N is a perfect square?

Details and assumptions

The condition of a 0 a \neq 0 follows because we have a 6 digit number.
The condition of d 0 d \neq 0 follows because 0 9 + 1 0 \neq 9 + 1 .


The answer is 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.

8 solutions

Steven Kwon
May 20, 2014

Note that we can re-write N N as N = 1001 ( 100 a + 10 b + c ) + 1 N=1001(100a+10b+c)+1 . Let N = n 2 N=n^2 . We will look for solutions that work for n using modular arithmetic. Taking the equation mod 7, we get n 2 = 1 ( m o d 7 ) n^2=1 \pmod{7} . Similarly we also have n 2 = 1 ( m o d 11 ) n^2=1 \pmod{11} and n 2 = 1 ( m o d 13 ) n^2=1 \pmod{13} . So we have a few cases to try. (Although there appears to be a lot of cases, several of them follow from others.):

1) n = 1 ( m o d 7 , 11 , 13 ) n=1 \pmod {7,11,13} . In this case we see that there are no values of n that work where a>0, since n = 1 n=1 works and the Chinese Remainder Theorem tells us that this is the only solution (mod 7 11 13=1001). Hence there are no solutions in this case.

2) n = 1 n=1 (mod 7,11) and n = 1 n=-1 (mod 13). We quickly see that n=155. However, since 15 5 2 155^2 has less than 6 digits, we see that this case fails.

3) n = 1 n=1 (mod 7,13) and n = 1 n=-1 (mod 11). We can see that n=274. But similarly, 27 4 2 274^2 has less than 6 digits, and so this case fails too.

4) n = 1 n=1 (mod 11,13) and n = 1 n=-1 (mod 7). We see that n=573, and since 57 3 2 573^2 has 6 digits this number works.

5) n = 1 n=-1 (mod 7,11) and n = 1 n=1 (mod 13) Note that this is analogous to case 2, except for the fact that the sign of n n is changed. Thus we quickly see that n = 155 = 846 n=-155=846 (mod 1001) works.

6) n = 1 n=-1 (mod 7,13) and n = 1 n=1 (mod 11). Similarly, we have n = 274 = 727 n=-274 =727 (mod 1001).

7) n = 1 n=-1 (mod 11,13) and n = 1 n=1 (mod 7). Similarly, we have n = 573 = 428 n=-573 =428 (mod 1001).

8) n = 1 n=-1 (mod 7,11,13) This simply yields n = 1000 n=1000 (mod 1001), which fails. Therefore, there are 4 total possible solutions.

1 minor detail was left out. What is missing?

Calvin Lin Staff - 7 years ago

Log in to reply

Is it that mod 1001, there's no more than one possibility for n n in each case, because 317 n < 1000 317\leq n<1000 if N N has 6 digits?

Laurent Shorts - 4 years, 3 months ago

Log in to reply

I've no idea what you are trying to say (specifically how 317 came in).

It can be shown that N d c ( m o d 1001 ) N \equiv d - c \pmod{1001} , where N N satisfies the conditions of the question.

It is true that for any integer (not nec 6 digits ), then the remainder when n n is divided by 1001 is uniquely determined.

Calvin Lin Staff - 4 years, 3 months ago

Log in to reply

@Calvin Lin As N = n 2 N=n^2 , 317 = 1 0 6 317=\lceil\sqrt{10^6}\rceil so that N N has 6 digits.

What I was trying to say is that if n 155 n\equiv 155 (mod 1001), as in case (2) for example, then n n is not necessarily 155, but can be 1156, 2157, and so on. But as n < 1000 n<1000 , we now that all n + k 1001 n+k·1001 will be to big and we don't have to check them.

As this part was not in the solution above, I thought maybe it was the minor detail that you said was left out. It is quite obvious though, so I'm really not sure what you thought was left out :)

Laurent Shorts - 4 years, 3 months ago

Log in to reply

@Laurent Shorts Ah yes. I was going for " n 1000 n \leq 1000 " as the restriction to explain why we don't have to care about (say) n = 1002 n = 1002 .

Using the condition of 317 n 999 317 \leq n \leq 999 makes it very easy to do the proper checking :)

Thanks for clarifying!

Calvin Lin Staff - 4 years, 3 months ago
Mark Hennings
Oct 28, 2013

If N = a b c a b d = M 2 N = \overline{abcabd} = M^2 , then M 2 1 = 1001 × a b c M^2-1 = 1001\times\overline{abc} , and hence M 2 1 M^2-1 is divisible by 1001 = 7 × 11 × 13 1001 = 7\times11\times13 . Since 100000 N < 1000000 100000 \le N < 1000000 , we deduce that 316 < M < 1000 316 < M < 1000 . There are eight cases to consider (omitting the details of the Chinese Remainder Theorem calculations):

  1. If M 1 M \equiv 1 modulo 7 , 11 , 13 7,11,13 , then M 1 M \equiv 1 modulo 1001 1001 , and no such M M exists in the desired range.

  2. If M 1 M \equiv 1 modulo 7 , 11 7,11 , and M 1 M \equiv -1 modulo 13 13 , then M 155 M \equiv 155 modulo 1001 1001 , and so no M M exists in the desired range.

  3. If M 1 M \equiv 1 modulo 7 , 13 7,13 and M 1 M \equiv -1 modulo 11 11 , then M 274 M \equiv 274 modulo 1001 1001 , and so no M M exists in the desired range.

  4. If M 1 M \equiv 1 modulo 11 , 13 11,13 and M 1 M \equiv -1 modulo 7 7 then M 573 M \equiv 573 modulo 1001 1001 , so that M = 573 M=573 and N = 328329 N = 328329 .

  5. If M 1 M \equiv 1 modulo 7 7 and M 1 M \equiv -1 modulo 11 , 13 11,13 , then M 573 M \equiv -573 modulo 1001 1001 , so that M = 428 M=428 and N = 183184 N = 183184 .

  6. If M 1 M \equiv 1 modulo 11 11 and M 1 M \equiv -1 modulo 7 , 13 7,13 , then M 274 M \equiv -274 modulo 1001 1001 , so that M = 727 M = 727 and N = 528529 N=528529 .

  7. If M 1 M \equiv 1 modulo 13 13 and M 1 M \equiv -1 modulo 7 , 11 7,11 , then M 155 M \equiv -155 modulo 1001 1001 , so that M = 846 M=846 and N = 715716 N=715716 .

  8. If M 1 M \equiv -1 modulo 7 , 11 , 13 7,11,13 then M 1 M \equiv -1 modulo 1001 1001 , and so no M M exists in the desired range.

Thus there are just 4 4 numbers N N of the desired type.

This problem appeared in British Mathematical Olympiad 1993 Round 1.

A Brilliant Member - 7 years, 7 months ago

hate "case-uistics", here's a java proggie for that.

public class DigitsABCABD {
    private static boolean isPerfectSquare(long input) {
        long root = (long) Math.sqrt(input);
        return ((root * root) == input);
    }

    public static void main(String[] args) {
    int resultsFound = 0;
        for (int a=1; a <= 9; a++) {
        for (int b=0; b <= 9; b++) {
                for (int c=0; c <= 9; c++) {
                    int d = c+1;
            try {
                String NStr = String.valueOf(a) +
                    String.valueOf(b) +
                String.valueOf(c) +
                String.valueOf(a) +
                String.valueOf(b) +
                            String.valueOf(d);
                        int N = Integer.parseInt(NStr);
                if (isPerfectSquare(N)) {
                            resultsFound++;
                            System.out.println("Found " + N + ", total " + resultsFound);
                        }
                    } catch (Exception e) {
                        System.err.println(e);
                    }
                }
            }
        }
    }
}

Found 183184, total 1
Found 328329, total 2
Found 528529, total 3
Found 715716, total 4

Angel Leon - 7 years, 7 months ago

Log in to reply

After failing to solve this mathematically, I also wrote a programme and it gave me the same results! I used Python instead. Programmers rock!! Keep up the good work!

Mark Mottian - 7 years, 7 months ago

Nice! Clean and clear, thanks for your great solution!!

Christopher Boo - 7 years, 7 months ago

Did the same.

Vimal Khetan - 1 year, 2 months ago
Eng Ngee H'ng
Nov 1, 2013

N = a b c a b d = a b c a b c + 1 = a b c ( 1001 ) + 1 N = \overline{abcabd} = \overline{abcabc} + 1 = \overline{abc} (1001) + 1 .

Let N = n 2 N = n^{2} , where n n is a positive integer. Thus a b c ( 1001 ) + 1 = n 2 \overline{abc} (1001) + 1 = n^{2} or a b c ( 1001 ) = n 2 1 = ( n 1 ) ( n + 1 ) \overline{abc} (1001) = n^{2} -1 = (n-1)(n+1) .

As 100 a b c 999 100 \leq \overline{abc} \leq 999 , so 100 ( 1001 ) + 1 a b c ( 1001 ) + 1 999 ( 1001 ) + 1 100(1001) + 1 \leq \overline{abc} (1001) + 1 \leq 999(1001) + 1 .

Thus 31 6 2 = 99856 100101 n 2 100 0 2 1 + 1 = 100 0 2 316^{2} = 99856 \leq 100101 \leq n^{2} \leq 1000^{2} - 1 + 1 = 1000^{2}

As n > 0 , 316 n 1000 n > 0,316 \leq n \leq 1000 .

Consider a b c ( 1001 ) = ( n 1 ) ( n + 1 ) \overline{abc} (1001) = (n-1)(n+1)

The prime factorisation of 1001 = 7 11 13 1001 = 7 * 11 * 13 . As n 1 n-1 and n + 1 n+1 have difference 2, they cannot have common factor larger than 2. The equation above shows that the prime factors 7, 11 and 13 divide n 1 n-1 or/and n + 1 n+1 .So 7, 11, 13 each divide only n 1 n-1 or n + 1 n+1 .

It can be seen that 2 of the primes divide 1 of n 1 n-1 and n + 1 n+1 while the last prime divides the other.

There are 3 cases. First, n 1 n-1 or n + 1 n+1 is divisible by 11 13 = 143 11 * 13 = 143 while the other is divisible by 7. Secondly, n 1 n-1 or n + 1 n+1 is divisible by 7 13 = 91 7 * 13 = 91 while the other is divisible by 11. Lastly, n 1 n-1 or n + 1 n+1 is divisible by 7 11 = 77 7 * 11 = 77 while the other is divisible by 13.

We have 315 n 1 < n + 1 1001 315 \leq n-1 < n+1 \leq 1001 . Thus we only need check the multiples of 143, 91 and 77 in this range and set them as n 1 n-1 or n + 1 n+1 while checking whether the other of the pair passes the test of divisibility by the 3rd prime.

This yields ( n 1 , n + 1 ) = ( 427 , 429 ) , ( 572 , 574 ) , ( 726 , 728 ) , ( 845 , 847 ) (n-1,n+1) = (427,429), (572,574), (726,728), (845,847) .

So n = 428 , 573 , 727 , 846 n = 428, 573, 727, 846 . From a b c ( 1001 ) = n 2 1 \overline{abc} (1001) = n^{2} -1 , we obtain
a b c = n 2 1 1001 \overline{abc} = \frac{n^{2} -1}{1001} . So a b c = 183 , 328 , 528 , 715. \overline{abc} = 183, 328, 528, 715.

Therefore N = a b c a b d = 183184 , 328329 , 528529 , 715716 N = \overline{abcabd} = 183184, 328329, 528529, 715716 .

Based on my finding, I used up an hour to find the squared of from 317 317 to 999 999 . Since 100000 = 316.227766016 \sqrt {100 000} = 316.227766016 . Among all 683 683 numbers, there are 6 6 perfect squares satisfy the following condition of a b c a b d abcabd . These numbers are...

42 8 2 = 183184 428^{2} = 183 184 54 8 2 = 300304 548^{2} = 300 304 57 3 2 = 328329 573^{2} = 328 329 72 7 2 = 528529 727^{2} = 528 529 84 6 2 = 715716 846^{2} = 715 716 85 6 2 = 732736 856^{2} = 732 736

Since d = c + 1 d = c + 1 , 300304 300 304 and 732736 732 736 does not satisfy the following condition. Hence, there are 4 \boxed{4} solutions.

You are really hardcore

Saad Haider - 7 years, 7 months ago
Bhaskar Pandey
May 31, 2021
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
def square(num):
    n=1
    while(n*n<num):
        n += 1
    return n*n==num
for i in range(100,1000):
    if square(i*1000+i+1):
        print(i)
#Output: 
#328
#528
#715
#999

Carsten Meyer
May 6, 2020

Let n : = a b c n:=\overline{abc} . With d = c + 1 d=c+1 , we can simplify the perfect square N N : N = a b c a b c + 1 = 1001 n + 1 = ! m 2 1001 n = ( m + 1 ) ( m 1 ) 1001 = 7 11 13 \begin{aligned} N&=\overline{abcabc}+1=1001n+1\overset{!}{=}m^2 &&&\Rightarrow&&&& 1001n&=(m+1)(m-1)&&&&&\left| 1001=7\cdot 11\cdot 13 \right. \end{aligned}

Each of the prime factors of 1001 must divide one of the two factors on the right. If we collect the prime factors into p , q p,\: q , respectively, we get a different diophantine equation to solve for each factorization of 1001: 1001 = p q : m + 1 = p x m 1 = q y } 2 = p x q y , x , y Z m 2 1 = p q x y , n = m 2 1 1001 = x y \begin{aligned} 1001&=pq: &&& \left.\begin{aligned} m+1&=px\\ m-1&=qy \end{aligned}\right\}&& 2&=px-qy,& x,\:y&\in\mathbb{Z}&&&&&\left|m^2-1=pqxy,\right.&&n&=\frac{m^2-1}{1001}=xy \end{aligned}

Notice the value of m 2 1 m^2-1 does not change if we switch the signs of both p , q p,\:q , or if we interchange them: It is enough to consider factorizations of 1001 with 0 < p q 0<p\leq q . We are left with only four cases, and p , q p,\:q are coprime in all of them:

p q ( ) n = x y 1 1001 2 = x 1001 y ( x y ) = ( 1 1001 0 1 ) ( 2 k ) , k Z ( 2 + 1001 k ) k 7 143 2 = 7 x 143 y ( x y ) = ( 41 143 2 7 ) ( 2 k ) , k Z ( 82 + 143 k ) ( 4 + 7 k ) 11 91 2 = 11 x 91 y ( x y ) = ( 25 91 3 11 ) ( 1 k ) , k Z ( 25 + 91 k ) ( 3 + 11 k ) 13 77 2 = 13 x 77 y ( x y ) = ( 6 77 1 13 ) ( 2 k ) , k Z ( 12 + 77 k ) ( 2 + 13 k ) \begin{aligned} \begin{array}{r|r|l c l l | l} p & q & &\red{(*)} & & &n=xy\\[.25em] \hline 1 & 1001 & 2=x-1001y& \:\: \Rightarrow\:\: & \begin{pmatrix}x\\y\end{pmatrix} = \begin{pmatrix} 1&1001\\ 0&1 \end{pmatrix}\begin{pmatrix}2\\k\end{pmatrix}, &\:\: k\in\mathbb{Z}& (2+1001k)k\\[1em] 7 & 143 & 2=7x-143y& \Rightarrow & \begin{pmatrix}x\\y\end{pmatrix} = \begin{pmatrix} 41&143\\ 2&7 \end{pmatrix}\begin{pmatrix}2\\k\end{pmatrix}, &\:\: k\in\mathbb{Z}& (82+143k)(4+7k)\\[1em] 11 & 91 & 2=11x-91y& \Rightarrow & \begin{pmatrix}x\\y\end{pmatrix} = \begin{pmatrix} 25&91\\ 3&11 \end{pmatrix}\begin{pmatrix}\red{1}\\k\end{pmatrix}, &\:\: k\in\mathbb{Z}& (25+91k)(3+11k)\\[1em] 13 & 77 & 2=13x-77y& \:\: \Rightarrow\:\: & \begin{pmatrix}x\\y\end{pmatrix} = \begin{pmatrix} 6&77\\ 1&13 \end{pmatrix}\begin{pmatrix}2\\k\end{pmatrix}, &\:\: k\in\mathbb{Z}& (12+77k)(2+13k) \end{array} \end{aligned} Our unknown number is restricted by n { 102 ; ; 987 } n\in\{102;\:\ldots;\:987\} . These restrictions determine which k k we may choose. p k n N 1 7 1 183 183184 0 328 328329 11 1 528 528529 13 1 715 715716 4 distinct solutions! \begin{aligned} \begin{array}{r|r|r|r} p & k & n & N \\[.5em]\hline 1 & & & \\[.5em]\hline 7 & -1& 183& 183184\\[.5em] & 0 & 328 & 328329\\[.5em]\hline 11 & -1& 528&528529\\[.5em]\hline 13 & -1 & 715&715716 \end{array}&&&&\Rightarrow &&&&\boxed{4}\text{ distinct solutions!} \end{aligned} It's easy to see there are no other possibilities, because the parabolas x y xy all have both zeros and their global minimum in [ 1 ; 0 ] [-1;\:0] .


Rem.: In ( ) \red{(*)} , we use the solution for the general linear diophantine equation: p x q y = r , p , q , r Z , gcd ( p , q ) = 1 ( x y ) = ( x 0 q y 0 p ) ( r k ) , k Z \begin{aligned} px-qy&=r,&&&p,\:q,\:r&\in\mathbb{Z},& \gcd(p,\:q)&=1 &&&\Rightarrow &&&&\begin{pmatrix}x\\y\end{pmatrix}&=\begin{pmatrix} x_0 & q\\ y_0 & p \end{pmatrix}\begin{pmatrix}r\\k\end{pmatrix},&k\in\mathbb{Z} \end{aligned}

The pair ( x 0 , y 0 ) (x_0,\:y_0) is any solution of p x 0 q y 0 = 1 px_0-qy_0=1 , obtained by Euclid's Algorithm or simply guessing. In the third row of the table, k k was shifted to get the smallest non-negative solution at k = 0 k=0 .

K T
Feb 14, 2019

N = 100100 a + 10010 b + 1001 c + 1 N=100100a+10010b+1001c+1 . Let N = x 2 N=x^2 so that 316 < x < 1000 316<x<1000 and N 1 = 1001 ( 100 a + 10 b + c ) = ( x + 1 ) ( x 1 ) N-1=1001(100 a + 10 b + c)=(x+1)(x-1) . Since 1001 = 7 × 11 × 13 1001=7×11×13 we have

7 × 11 × 13 × ( 100 a + 10 b + c ) = ( x + 1 ) ( x 1 ) 7×11×13×(100 a + 10 b + c)=(x+1)(x-1)

Each prime factor must be a factor of either x + 1 x+1 or x 1 x-1 . So, respecting the upper bound for x we cannot have them all in either x + 1 x+1 or x 1 x-1 . There are six possible cases

  • x+1 a multiple of 7×11 and  x-1 a multiple of 13. Or x 1 ( m o d 77 ) x \equiv -1 \pmod{77} and x 1 ( m o d 13 ) x \equiv 1 \pmod{13} we find x = 846 ( m o d 1001 ) x=846 \pmod {1001} . N = 715716 N=715716
  • x+1 a multiple of 13 and  x-1 a multiple of 7×11, Or x 1 ( m o d 77 ) x \equiv 1 \pmod{77} and x 1 ( m o d 13 ) x \equiv -1 \pmod{13} we find x = 846 = 155 ( m o d 1001 ) x=-846=155 \pmod {1001} . N = 24025 N=24025 . This disqualifies as a=0.
  • x+1 a multiple of 7×13 and  x-1 a multiple of 11. x 1 ( m o d 91 ) x \equiv -1 \pmod{91} and x 1 ( m o d 11 ) x \equiv 1 \pmod{11} we find x = 727 ( m o d 1001 ) x=727 \pmod {1001} . N = 528529 N=528529
  • x+1 a multiple of 11 and  x-1 a multiple of 7×13. we find x = 727 = 274 ( m o d 1001 ) x=-727=274 \pmod {1001} . N = 75076 N=75076 This disqualifies as a=0.
  • x 1 ( m o d 143 ) x \equiv -1 \pmod{143} and x 1 ( m o d 7 ) x \equiv 1 \pmod{7} , x = 428 ( m o d 1001 ) x=428 \pmod {1001} . N = 183184 N=183184
  • x 1 ( m o d 143 ) x \equiv 1 \pmod{143} and x 1 ( m o d 7 ) x \equiv -1 \pmod{7} , x = 428 = 573 ( m o d 1001 ) x=-428=573 \pmod {1001} . N = 328329 N=328329

So we have 4 \boxed{4} solutions.

As an example for finding x I show the 3rd case below

x 1 ( m o d 91 ) x\equiv-1\pmod{91}

x = 90 + 91 t x=90+91t

x 2 + 3 t ( m o d 11 ) x\equiv2+3t \pmod{11}

Also, x 1 ( m o d 11 ) x\equiv1 \pmod{11}

3 t 1 12 ( m o d 11 ) 3t\equiv-1\equiv-12 \pmod{11}

t 4 7 ( m o d 11 ) t\equiv-4\equiv7 \pmod{11}

x = 90 + 91 × 7 = 727 x=90+91×7=727

N = x 2 = 528529 N=x^2=528529

Edward Jiang
Oct 31, 2013

Use PARI.

Can you explain how you used PARI?

Calvin Lin Staff - 7 years, 7 months ago

Log in to reply

I don't know how to post codes.

Edward Jiang - 7 years, 7 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...