Suppose a b c and d e f are three-digit numbers such that ( a b c + d e f ) 2 = a b c d e f .
Find a b c .
Details and assumptions
a b c means 1 0 0 a + 1 0 b + 1 c , as opposed to a × b × c . As an explicit example, for a = 2 , b = 3 , c = 4 , a b c = 2 3 4 and not 2 × 3 × 4 = 2 4 .
The number 1 2 = 0 1 2 is a 2-digit number, not a 3-digit number.
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.
Great job! Very clear and complete solution.
Well , isn't Sharvik's solution easier ?
Let M = a b c & N = d e f . So, ( M + N ) 2 = 1 0 0 0 M + N
Expansion gives M 2 + M ( 2 N − 1 0 0 0 ) + ( N 2 − N ) = 0 which is a quadratic in M .
It's discriminant Δ = ( 2 N − 1 0 0 0 ) 2 − 4 ( N 2 − N ) = 1 0 6 − 3 9 9 6 N = 4 ( 2 5 0 0 0 0 − 9 9 9 N )
Clearly, 2 5 0 0 0 0 − 9 9 9 N < 2 5 0 0 0 0 = 5 0 0
So we may put: 2 5 0 0 0 0 − 9 9 9 N = ( 5 0 0 − i ) 2 for some positive integer i . Finally, i ( 1 0 0 0 − i ) = 9 9 9 N
The equation is quite symmetric in i (due to presence of ( 1 0 0 0 − i ) ),so we may assume: 2 7 ∣ i ⇒ i = 2 7 r for some r. Plugging in, we get: r ( 1 0 0 0 − 2 7 r ) = 3 7 N Now 37 doesn't divide i , for then it would have become 999 itself,not possible. So 1 0 0 0 − 2 7 r = 3 7 p for some p.
Hence, r = 2 7 1 0 0 0 − 3 7 p = 3 7 − p − 2 7 1 0 p − 1 which is integral for p = 1 9 . Thus, r = 1 1 , i = 2 9 7 , N = 2 0 9 & finally M = 4 9 4 .
Nice solution! Please look at the author's comment for some fine details.
Oh,there's a slight discrepancy... I could assume 2 7 ∣ i since 9 9 9 = 3 3 ∗ 3 7 & i & ( 1 0 0 0 − i ) cannot be both divisible by 3 or by 37. This is easily verifiable by considering these ( m o d 3 ) & ( m o d 3 7 ) respectively.
let abc be x and def be y (here abc and def are the numbers)
Then ( x + y ) 2 = 1 0 0 0 × x + y
( x + y ) 2 = 9 9 9 x + x + y
( x + y ) × ( x + y − 1 ) = 9 9 9 × x
( x + y ) × ( x + y − 1 ) = 2 7 × 3 7 × x
So product of two consecutive positive integers = 2 7 × 3 7 × x .
Now out of two consecutive integers only one is divisible by 3 ,therefore
Numbers ( x + y ) and ( x + y − 1 ) will be of the form 27 k and 37 m where m × k = x (here m and k should be positive)
Now numbers 27 k and 37 m should be consecutive
If 27 k -37 m =1
Then k = (1+10 m )/27 + m
m =8 and k = 11 will be one solution but the product of k and m is 88 but x is 3 digit number
and the next solution is m =35 and k = 48 whose product is 4 digit.
If 37 m -27 k =1
Then m = (1-10 k )/37 + k
k =19 , m =26 and so x=494
so abc =494
Same thing which I did, although after the problem set expired.
Nice solution ,
Typo in the line - ...is 88 and x ... shouldn't it be ' but ' ?
Thank you
Let M = a b c and N = d e f . Then the given equation becomes ( M + N ) 2 = 1 0 0 0 M + N .
If we expand the left-hand side, subtract 1 0 0 0 M + N from both sides, and solve for M using the quadratic equation, we get M = 2 1 0 0 0 − 2 N ± ( 1 0 0 0 − 2 N ) 2 − 4 ( N 2 − N ) ,
which works out to M = 5 0 0 − N ± 5 0 0 2 − 9 9 9 N .
Since M needs to be an integer, 5 0 0 2 − 9 9 9 N must be a perfect square, so we let 5 0 0 2 − 9 9 9 N = K 2 for some integer K.
Switching 9 9 9 N with K 2 and factoring the resulting difference of squares, we get 9 9 9 N = ( 5 0 0 + K ) ( 5 0 0 − K ) . That tells us 9 9 9 ∣ ( 5 0 0 + K ) ( 5 0 0 − K ) .
Now we factor 999 into 3 3 ∗ 3 7 and try to come up with more useful divisibility statements. First, notice that only one of (500+K) and (500-K) can be divisible by 3. That means it must also be divisible by 3 3 . That, in turn, means the other expression must be divisible by 37. (Otherwise, we'd have 999|(500+K), which leads to the 1-digit solution N=1.)
Let's investigate the case where 5 0 0 − K ≡ 0 ( m o d 2 7 ) and 5 0 0 + K ≡ 0 ( m o d 3 7 ) .
Solving for K in each, we get the set of congruences
K ≡ 1 4 ( m o d 2 7 )
K ≡ 1 8 ( m o d 3 7 )
Using the second mod relation, we can let K = 1 8 + 3 7 L for some nonnegative integer L. Plugging into the first relation, we get
1 8 + 3 7 L ≡ 1 4 ( m o d 2 7 )
1 0 L ≡ 2 3 ( m o d 2 7 )
Noticing that 2 3 ≡ 5 0 ≡ 1 0 ∗ 5 ( m o d 2 7 ) we find L ≡ 5 ( m o d 2 7 ) . 5 is the only value of L that prevents 5 0 0 − K from going negative, so L = 5 .
We can now find the values of our other variables:
K = 1 8 + 3 7 ∗ 5 = 2 0 3
9 9 9 N = 7 0 3 ∗ 2 9 7 , so N = 2 0 9
M = 5 0 0 − 2 0 9 ± 2 0 3 . We use M = 4 9 4 since M must have 3 digits.
We verify that ( 4 9 4 + 2 0 9 ) 2 = 4 9 4 2 0 9 , and our work is complete! M = 4 9 4 .
(Note: the other case, where 5 0 0 + K ≡ 0 ( m o d 2 7 ) and 5 0 0 − K ≡ 0 ( m o d 3 7 ) , produces no valid solutions).
Let x = a b c and y = d e f . Then we have x 2 + 2 x y + y 2 = 1 0 0 0 x + y y 2 + ( 2 x − 1 ) y + x 2 − 1 0 0 0 x = 0 . We know that y must be integer, so D = ( 2 x − 1 ) 2 − 4 ( x 2 − 1 0 0 0 x ) = 3 9 9 6 x + 1 must be square of an integer. Let 3 9 9 6 x + 1 = m 2 . Then 3 9 9 6 x = ( m − 1 ) ( m + 1 ) We know that m − 1 and m + 1 have same parity, Then since 3 9 9 6 x is even, both m − 1 and m + 1 are even. 3 9 9 6 = 4 ∗ 2 7 ∗ 3 7 . From here, we take some cases.
Case 1. m − 1 = 2 a c , and m + 1 = 2 b d , with a b = 9 9 9 , and c d = x . If 3 ∣ m − 1 , then 3 ∤ m + 1 . Also if 3 ∣ m + 1 , then 3 ∤ m − 1 So between a or b is divisible by 3.
Case 1a. If 3 ∣ a , then 3 ∤ b . So the only possibility for a is a = 2 7 , thus b = 3 7 , since 2 7 ∗ 3 7 = 9 9 9 . This will give 2 7 c − 1 = 3 7 d . Means that c = 2 7 3 7 d + 1 = d + 2 7 1 0 d + 1 is an integer. We know that for d = 8 , c is an integer, and also for d = 2 7 e + 8 , for an integer e . For d = 8 we have c = 1 1 , so x = 8 8 . It's impossible. For e > 0 , then we will have x > 1 0 0 0 which is also impossibru.
Case 1b. If 3 ∤ a and 3 ∣ b , then the only possibility for b is b = 2 7 , and a = 3 7 . This will give 3 7 c − 1 = 2 7 d . And with the same argument from case 1a., we will not have x that we want.
Case 2. If m − 1 = 4 a c , and m + 1 = b d . Same argument, the value between a or b is 2 7
Case 2a. If b = 2 7 , then a = 3 7 . This will gives 1 4 8 c + 2 = 2 7 d . Then d = 2 7 1 4 8 c + 2 = 5 c + 2 7 1 3 c + 2 is an integer. We know that for c = 4 , d is an integer. So we can write c = 2 7 e + 4 , for integer e . For c = 4 , then d = 2 2 , which gives x = 8 8 . It's impossible. For e > 0 , we will have x > 1 0 0 0 , which is also impossible.
Case 2b. For a = 2 7 and b = 3 7 . This will give 1 0 8 c + 2 = 3 7 d . So d = 3 7 1 0 8 c + 2 = 3 c + 3 7 2 − 3 c is an integer. For c = 1 3 , then d is an integer. So we can write c = 3 7 e + 1 3 , for integer e . If c = 1 3 , then d = 3 8 , which gives x = 4 9 4 . If e > 0 , then we will get x > 1 0 0 0 , which is impossible.
After all of case, we finally get x = 4 9 4 . For x = 4 9 4 , then D = 1 4 0 5 . So y = 2 − 2 ∗ 4 9 4 + 1 + 1 4 0 5 = 2 0 9 So a b c = x = 4 9 4
Let x = a b c and y = d e f . Then we have ( x + y ) 2 = 1 0 0 0 x + y .
To simplify things further, let k = x + y . This would give us y = k − x . Note that k should be in the range 0 < k < 1 0 0 0 , since 0 < a b c d e f = k 2 < 1 0 0 0 0 0 0 .
Substituting k = x + y and y = k − x into the original equation, we arrive at k 2 = 1 0 0 0 x + k − x or k 2 − k = 9 9 9 x .
And so we see that k ( k − 1 ) is divisible by 9 9 9 = 2 7 × 3 7 .
Since k and k − 1 are relatively prime, there are four cases:
Case 1: k is divisible by 9 9 9 . The only possible value of k is 9 9 9 since 0 < k < 1 0 0 0 . Thus in this case a b c x y z = k 2 = 9 9 8 0 0 1 , but 0 0 1 is not a three-digit number, so this is invalid.
Case 2: k − 1 is divisible by 9 9 9 . The only k in the range 0 < k < 1 0 0 0 that satisfies this is k = 1 , but this is certainly not valid.
Case 3: k − 1 is divisible by 3 7 and k is divisible by 2 7 .
Thus k ≡ 1 ( m o d 3 7 ) and k ≡ 0 ( m o d 2 7 ) .
By the Chinese Remainder theorem, k ≡ 2 9 7 ( m o d 2 7 × 3 7 ) , or k ≡ 2 9 7 ( m o d 9 9 9 ) . The only value of k in the range 0 < k < 1 0 0 0 is 2 9 7 . Thus a b c d e f = 2 9 7 2 = 8 8 2 0 9 , but 0 8 8 is not a three-digit number, so this is also invalid.
Case 4: k − 1 is divisible by 2 7 and k is divisible by 3 7 .
Thus k ≡ 1 ( m o d 2 7 ) and k ≡ 0 ( m o d 3 7 ) .
By the Chinese Remainder theorem, k ≡ 7 0 3 ( m o d 2 7 × 3 7 ) , or k ≡ 7 0 3 ( m o d 9 9 9 ) . The only value of k in the range 0 < k < 1 0 0 0 is 7 0 3 . Thus a b c d e f = 7 0 3 2 = 4 9 4 2 0 9 . This satisfies the conditions of the question.
Hence, a b c = 4 9 4
[This method requires some tedious calculation but it reduces the number of trials to a mere 37]
Since a b c d e f is a 5 digit perfect square, then 1 0 5 ≤ a b c d e f < 1 0 6 . Or 3 1 6 < a b c d e f ≤ 9 9 9
Let A = a b c , B = d e f
Then essentially, we want to solve ( A + B ) 2 = 1 0 0 0 A + B with constraints 1 0 0 ≤ A , B ≤ 9 9 9 , 3 1 6 ≤ A + B ≤ 9 9 9
Take mod of 37 to both sides (knowing that 1 0 0 0 m o d 3 7 = 1 ), we have ( A + B ) 2 ≡ ( A + B ) . Or A + B ≡ 0 , 1 ( m o d 3 7 )
For A + B ≡ 0 ( m o d 3 7 ) , the possible values of A + B are 3 3 3 , 3 7 0 , 4 0 9 , … , 9 6 2 , 9 9 9
Similarly, for A + B ≡ 1 ( m o d 3 7 ) , the possible values of A + B are 3 3 4 , 3 7 1 , 4 1 0 , … , 9 6 3
With these values, we apply trial and error to ( A + B ) 2 = 1 0 0 0 A + B gives A + B = 7 0 3 as the only possible solution
⇒ 7 0 3 2 = 4 9 4 2 0 9 = ( 4 9 4 + 2 0 9 ) 2 ⇒ a b c = A = 4 9 4
I have a question, isnt abcdef a 6 digit perfect square? How come you said it is a 5 digit perfect perfect square?
Log in to reply
Yeah you're right. I can't even count to 6. HAHA!
When you say "With these values, we apply trial and error to (A+B)2=1000A+B gives A+B=703 as the only possible solution", How do you get that by trial and error?
Log in to reply
Take for example, if A + B = 3 7 0 , then ( A + B ) 2 = 1 3 6 9 0 0 = 1 0 0 0 A + B , this gives A = 1 3 6 , B = 9 0 0 but it didn't satisfy A + B = 3 7 0
9 9 9 = 3 3 ⋅ 3 7
So there's four possibilities. With Euclid's algorithm, we find 2 7 ⋅ 1 1 − 3 7 ⋅ 8 = 1 , and so, modulo 999, x + y must be:
x + y ≡ 0 mod 37 | x + y ≡ 1 mod 37 | |
x + y ≡ 0 mod 27 | 0 | 2 7 ⋅ 1 1 = 2 9 7 |
x + y ≡ 1 mod 27 | − 8 ⋅ 3 7 = − 2 9 6 ≡ 7 0 3 | 1 |
As ( x + y ) 2 is a 6-digits number, x + y < 1 0 0 0 , so we only have to check x + y in 1, 297, 703 and 999.
Only possibility left: x = 4 9 4 , y = 2 0 9
1 2 3 4 5 6 7 8 9 |
|
I used the following C program to find such numbers;
void main() { unsigned long i,x,y,rem[6]; clrscr(); for(x=317;x<=999;x++) { y=x x; for(i=0;i<6;i++) { rem[i]=y%10; y=y/10; } if((rem[0]+10 rem[1]+100 rem[2])+(rem[3]+10 rem[4]+100*rem[5])==x) printf("\n%lu",x); } getch(); } The output is 703 and 999. Now 999^2=998001 in which 001 is not of 3 digits. And 703^2=(494+209)^2=494209 Hence 703 is the result.
Hahaha nice!
We let a b c = x and d e f = y .
The equation becomes ( x + y ) 2 = 1 0 0 0 x + y . We expand it to get x 2 + 2 x y + y 2 = 1 0 0 0 x + y . Treating it into a quadratic in x makes it x 2 + ( 2 y − 1 0 0 0 ) x + ( y 2 − y ) = 0 . x = ( 2 ) ( 1 ) − ( 2 y − 1 0 0 0 ) ± ( 2 y − 1 0 0 0 ) 2 − 4 ( 1 ) ( y 2 − y ) = 2 − ( 2 y − 1 0 0 0 ) ± 4 y 2 − 4 0 0 0 y + 1 0 0 0 0 0 0 − 4 y 2 + 4 y , which is equal to 5 0 0 − y ± 2 5 0 0 0 0 − 9 9 9 y
Hence 2 5 0 0 0 0 − 9 9 9 y must be a perfect square. We let 2 5 0 0 0 0 − 9 9 9 y = k 2 . So 5 0 0 + k ) ( 5 0 0 − k ) = 9 9 9 y . We let 5 0 0 + k = p and 5 0 0 − k = q , where k could be negative. p + q = 1 0 0 0 and their product is a multiple of 9 9 9 . Hence it must be a multiple of both 2 7 and 3 7 .
Since 1 0 0 0 is not a multiple of 3 , not both p and q could be multiples of 3 . Thus the multiple of 37 is not a multiple of 3, and the number that is not the multiple of 37 is a multiple of 27.
WLOG let p be the multiple of 37. Then we let p = 3 7 m and q = 2 7 n . 3 7 m + 2 7 n = 1 0 0 0 . Reducing m o d 3 7 , we know that 2 7 n is congruent to 1 m o d 3 7 .
By Guess and Check, we know that n = 2 9 7 , as n is at most 9 9 9 .
Hence k = 2 0 3 , and y = 9 9 9 ( 7 0 3 ) ( 2 9 7 ) = 2 0 9 , and x = 2 9 1 ± 2 5 0 0 0 0 − 9 9 9 ( 2 0 9 ) = 2 9 1 ± 2 0 3 . Since x is a 3 digit number, x = 2 9 1 + 2 0 3 = 4 9 4 .
Since x = a b c , a b c = 4 9 4
Since there hasn't been programming questions for a while I decided to solve this one with Python using the code below. I defined a b c as x and d e f as y . Since we know that they are three digit numbers we can make the range between 1 0 0 and 9 9 9 . In the third line of the code I defined a b c d e f as ( 1 0 0 0 x ) + y as they are equivalent statements. If the equality holds the the next line of code is run which prints the value of x . This is the solution to the problem as x = a b c .
for x in range(100, 1000):
for y in range(100, 1000):
if (x+y)**2 == (1000*x)+y:
print(x)
When the code is executed the output for x is 4 9 4 .
step 1: go to this site Online Python Interpreter
step 2: copy paste this code, then run
for a in range(1,10):
>for b in range(0,10):
>>for c in range(0,10):
>>>for d in range(0,10):
>>>>for e in range(0,10):
>>>>>for f in range(0,10):
>>>>>>_abc=100*a+10*b+c
>>>>>>_def=100*d+10*e+f
>>>>>>_abcdef=100000*a+10000*b+1000*c+100*d+10*e+f
>>>>>>if ( abc+ def)**2 == _abcdef:
>>>>>>>print _abc
>>>>>>>break
Output: 494
I wouldn't encourage using Python to solve non-CS problems on Brilliant. Either way, it is not a very good program. You could just have used two loops: one for A and one for B with 1 0 0 ≤ A , B < 1 0 0 0 , and just check whether
( A + B ) 2 = 1 0 0 0 A + B .
Another thing, you do use
break
, but notice that it only breaks out of the last loop, not the other 5. So it isn't very effective.
Log in to reply
so youre thinking your just the good one.. Ok YOUR GOOD, I accepted it.. Are you happy now? =p
cheeeeeeeeeeeeeeeeeeeetah
Log in to reply
its not cheating... its resourcefulness...hahahaah
Log in to reply
It is not real resourcefulness. The real resourcefulness is being able to solve the problem without the computer's help. A comparison: a resourceful person can fix a bike with whatever is at hand. And anybody can fix a bike with money and a repair shop. Computer skills are valuable, but using them to solve this kind of problems is just cheating yourself of a good challenge.
One thing is that you use Python on your own to solve it, that is your problem. Other thing is that you are continue encouraging other people to use Python to solve the problems which misses completly the point and is what I have seen in many solutions you give. When we (people who haven't got the problem, like me) look the solutions of the problem, we want to see how it is solved using mathematica. So at least do not post your solution using these methods.
Using electronic help for solving Brilliant mathematics problems isn't legal, I guess!
Log in to reply
yeah ur ryt Sreejato.... those two guys above are just being so arrogant, thinking theyre just the one who can solve brilliant problems in the diffferent manner..
yeah ur ryt..! those two guys above are just being too arrogant.. thinking that they are the only one who can solve brilliant problems in the different way..=p
Log in to reply
I disagree. There are a lot of challenging computer science problems on the net, ProjectEuler for example. These problems are meant to be solved by hand. Also, as Tim pointed out, even if you wanted to use a computer to solve this problem, this algorithm is the most inefficient way to do so.
Problem Loading...
Note Loading...
Set Loading...
Let x = a b c and y = d e f . The problem can then be restated as finding the solution(s) of
( x + y ) 2 = 1 0 0 0 x + y 1 0 0 ≤ x , y < 1 0 0 0
Rewriting and solving for x :
0 = x 2 + 2 ( y − 5 0 0 ) x + y 2 − y x = 5 0 0 − y ± ( y − 5 0 0 ) 2 − ( y 2 − y ) = 5 0 0 − y ± 5 0 0 2 − 9 9 9 y
A necessary condition is thus that 5 0 0 2 − 9 9 9 y is the square of some integer, to be called k . We can write
9 9 9 y = 5 0 0 2 − k 2 = ( 5 0 0 − k ) ( 5 0 0 + k )
We are thus looking for a factorization 9 9 9 y = p q , where p and q are positive integers with p + q = 1 0 0 0 .
Note that 9 9 9 = 3 3 ⋅ 3 7 . Clearly p and q cannot both be divisible by 3 , since then p + q would also be divisible by 3 and hence not 1 0 0 0 . Therefore, one of the factors (let us say p ) must be divisible by 2 7 , i.e. p = 2 7 s for some integer s .
Furthermore, either p or q (or both) must be divisible by 3 7 . However, it cannot be p , since then it's divisible by 9 9 9 and this gives the solution p = 9 9 9 , q = 1 and thus y = 1 , which violates y ≥ 1 0 0 . Therefore, q must be divisible by 3 7 and we can write q = 3 7 t for some integer t .
We now have the equation
1 0 0 0 = p + q = 2 7 s + 3 7 t
Modulo 9 , this reads t ≡ 1 , which reduces the possible values of t to the set { 1 , 1 0 , 1 9 } . Trial and error reveals that the only solution is s = 1 1 and t = 1 9 . This gives p = 2 9 7 , q = 7 0 3 , y = s t = 2 0 9 and k = ∣ 5 0 0 − p ∣ = ∣ 5 0 0 − q ∣ = 2 0 3 .
For x we find
x = 5 0 0 − y ± 5 0 0 2 − 9 9 9 y = 5 0 0 − y ± k = 2 9 1 ± 2 0 3
The solution x = 2 9 1 − 2 0 3 = 8 8 violates x ≥ 1 0 0 , hence x = 2 9 1 + 2 0 3 = 4 9 4
( 4 9 4 + 2 0 9 ) 2 = 4 9 4 2 0 9