Abcd

Embed Size (px)

DESCRIPTION

Mathematics sums

Citation preview

So I asked it to try all of the possibilities:for(a=0,9,for(b=0,9,for(c=0,9,for(d=0,9,if(1000*a+100*b+10*c+d==(10*a+b)^2+(10*c+d)^2,print([a,b,c,d]))))))It gave me the following answers:[0, 0, 0, 0][0, 0, 0, 1][1, 2, 3, 3][8, 8, 3, 3]But I'm guessing that you want an algorithm that uses less work,something easier to do by hand rather than have a computer do it.Well, you are trying to solve the equation 1000*a + 100*b + 10*c + d = (10*a+b)^2 + (10*c+d)^2for integers a, b, c, and d in the range 0 through 9. My firstthought is to reduce mod 10, and then 100, which is equivalent tolooking at what happens to the rightmost digit, and then the tworightmost digits: d = b^2 + d^2 (mod 10).Start by checking each of the 10 possibilities for d, and each of the10 possibilities for b, and see which ones give the same last digiton each side of your equation. It turns out that the last-digitvalues of b^2 for b = 0, 1, 2, ... 9 are 0, 1, 4, 9, 6, 5, 6, 9, 4, 1and the last-digit values of d - d^2 are 0, 0, 8, 4, 8, 0, 0, 8, 4, 8The only matches are 0 and 4, so either the last digit is 0 (and b iszero and d is either 0, 1, 5, or 6) or the last digit is 4 (and b iseither 2 or 8, and d is either 2, 4, 7, or 9).Next, look at the last TWO digits: 10*c + d = 20*a*b + b^2 + 20*c*d + d^2 (mod 100).In fact, before you do that, just look at whether the second-from-the-right digit is odd or even: 10*c + d = b^2 + d^2 (mod 20).For each possible (b, d) pair, you can find out whether c needs to beodd or even. Then, you can try the five choices for c and see what ahas to be to solve the equation.You could also treat it as a quadratic equation in a, find thediscriminant, and then see which values for c give you a perfectsquare for the discriminant.Those are just a few ideas. I'm sure that there are other strategiestoo.If you have any questions about this or need more help, please writeback and show me what you have been able to do, and I will try tooffer further suggestions.