[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference rusure::math

Title:Mathematics at DEC
Moderator:RUSURE::EDP
Created:Mon Feb 03 1986
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:2083
Total number of notes:14613

1016.0. "number=(num+ber)^2" by AKQJ10::YARBROUGH (I prefer Pi) Mon Jan 23 1989 12:02

The number 998001 has the property that it is equal to the square of the 
sum of its halves, i.e.

	998001 = (998+001=999)^2

There is at least one other 6-digit integer with this property. Assume you
want to write a program to find it (them?). One could, of course, search
all the six-digit integers, but that's much too inelegant, not to say
expensive. How narrow can you make the search space by analysis? To say it 
another way, how few numbers need you test to be sure of finding all the 
solutons?

Lynn Yarbrough 
T.RTitleUserPersonal
Name
DateLines
1016.1AITG::DERAMODaniel V. {AITG,ZFC}:: D'EramoMon Jan 23 1989 17:0911
     Are you including numbers like 1 = 000001 = (000 + 001)^2
     in the search space?  Or only integers n such that
     100000 <= n <= 999999?
     
     One way to limit the search is to consider only squares of
     numbers <= sqrt(999999) < 1000.  So only examine n^2 for
     1 <= n <= 999 (or 317 <= n <= 999 if leading zeroes don't
     count).  Also the more significant half of the number must
     be even.
     
     Dan
1016.2Not elegant, fairly fast...VINO::EKLUNDDave EklundMon Jan 23 1989 17:1246
I don't know what you had in mind, but here's one way to approach it.
Answer follows form feed...

Let the 6 (or less?) digit number be X Y where X and Y are each three
digit numbers.  Then we can write the number as X*1000 + Y.
The problem statement gives us that (X + Y)^2 = X*1000 + Y

Solve for X gives:

X^2 + X*(2*Y - 1000) + (Y^2 - Y) = 0

Quadratic formula gives:

	X = 500 - Y +- sqrt( 500^2 -999*Y)

In order to have integer X, the Sqrt( 500^2 - 999*Y) must be an integer.
Call it N.  Then 

	N^2 = 500^2 -999*Y

A little reordering gives:

	(N+500)*(N-500) = -999*Y

But 999 has factors 3*3*3*37.  Therefore either N+500 or N-500 must be
divisible by 37, and there must be three factors of 3 in N+500 and N-500.

So we try all the multiples of 37 between 1 and 1000 (there are 27 such
numbers).  There are two values of N of interest, N = 203 and N = 499.

	(703 = 37*19, 297 = 27*11)
	(999 = 37*27, 1 = 1)

The first gives Y = 19*11 =  209 with solutions X = 88 and 494 (due to +-).
The second gives Y = 1 with solutions X = 998 and X = 0.

Therefore the solutions are:

	998001 (given)
	000001 (not really 6 digits)
	 88209 (ditto)
	494209 - a real second solution!

Dave


1016.3KOBAL::GILBERTOwnership ObligatesMon Jan 23 1989 20:0911
    Okay, how about:
    
    	abcdefgh = (abcd+efgh)^2
    Or:
    	abcdefghij = (abcde+fghij)^2
    
    Or:
    	abcdef = (ab+cd+ef)^3
    Or:
    	abcdefghi = (abc+def+ghi)^3
    
1016.4AITG::DERAMODaniel V. {AITG,ZFC}:: D'EramoMon Jan 23 1989 21:348
     re .3
     
>>     Okay, how about:
       ^^^^
     
     Only "Okay"?  I thought .2 was very good.
     
     Dan
1016.5Computer not neededAKQJ10::YARBROUGHI prefer PiTue Jan 24 1989 17:165
Well done! This is another of the problems from "The Puzzled Programmer" 
and shows once again that a little analysis ahead of time can save a lot of 
computing.

Lynn Yarbrough 
1016.6(abcd+efgh)^2 = abcdefghKOBAL::GILBERTOwnership ObligatesSat Jan 28 1989 17:5777
>     Only "Okay"?  I thought .2 was very good.
    
    Sorry.  Dave dispatched that one so easily, I was anxious to see how
    slightly harder forms of the problem would fare.


    Let's consider (abcd+efgh)^2 = abcdefgh.  As in .2, (X+Y)^2 = X*10000+Y,
    so

	X^2 + X*(2*Y - 10000) + (Y^2-Y) = 0,

	X = 5000 - Y +- sqrt ( 5000^2 - 9999*Y )

	N^2 = 5000^2 - 9999*Y

	(N + 5000) * (N - 5000) = -9999 * Y = -3*3*11*101*Y

    We can partition these factors amoung N+5000 and N-5000 in eight ways:

	N+5000 = u,		N-5000 = 3*3*11*101*v
	N+5000 = 3*3*u,		N-5000 = 11*101*v
	N+5000 = 11*u,		N-5000 = 3*3*101*v
	N+5000 = 3*3*11*u,	N-5000 = 101*v
	N+5000 = 101*u,		N-5000 = 3*3*11*v
	N+5000 = 3*3*101*u,	N-5000 = 11*v
	N+5000 = 11*101*u,	N-5000 = 3*3*v
	N+5000 = 3*3*11*101*u,	N-5000 = v

    In any case, we have N = f*u - 5000 = g*v + 5000, where f*g = 9999. 
    The solution to this is N = 9999*z + k, where z is a free variable
    integer, and k satisfies: k == 5000 (mod g), and k == -5000 (mod f).

    Eight applications of Euclid's algorithm and the Chinese remainder theorem
    yield the solutions for N:

	N = 9999*z - 5000*1*1    + 5000*9999*0	
	N = 9999*z - 5000*9*247  + 5000*1111*7	(9*247 = 1 (mod 1111))
	N = 9999*z - 5000*11*248 + 5000*909*8	(11*248 = 1 (mod 909))
	N = 9999*z - 5000*99*50  + 5000*101*50		(etc)
	N = 9999*z - 5000*101*50 + 5000*99*50	
	N = 9999*z - 5000*909*8  + 5000*11*248	
	N = 9999*z - 5000*1111*7 + 5000*9*247	(1111*7 = 1 (mod 9))
	N = 9999*z - 5000*9999*0 + 5000*1*1	

    And now, expanding the above folding multiples of 9999 into the z), we
    simply the expressions for N, and solve for Y = (5000^2 - N^2)/9999.

	N = 9999*z + 4999	Y =    1 - z*(2+9999*z)
	N = 9999*z + 2777	Y = 1729 - z*(2+9999*z)
	N = 9999*z + 2272	Y = 1984 - z*(2+9999*z)
	N = 9999*z +   50	Y = 2500 - z*(2+9999*z)
	N =-9999*z -   50	Y = 2500 - z*(2+9999*z)
	N =-9999*z - 2272	Y = 1984 - z*(2+9999*z)
	N =-9999*z - 2777	Y = 1729 - z*(2+9999*z)
	N =-9999*z - 4999	Y =    1 - z*(2+9999*z)

    (or, just four equations, realizing that N = (+-)(9999*z+...))

    Now X = 5000 - Y +- N.  For convenience, we drop the z stuff (note that
    |z| >= 1 would subtract at least 9997 from Y), and have:

	 N'	Y'	X'	X''
	 4999	0001	9998	0000
	 2777	1729	6048	0494
	 2272	1984	5288	0744
	 0050	2500	2550	2450

    And so we have the eight solutions:

	(0000+0001)^2 = 00000001
	(0494+1729)^2 = 04941729
	(0744+1984)^2 = 07441984
	(2450+2500)^2 = 24502500
	(2550+2500)^2 = 25502500
	(5288+1984)^2 = 52881984
	(6048+1729)^2 = 60481729
	(9998+0001)^2 = 99980001
1016.7yuckoAITG::DERAMODaniel V. {AITG,ZFC}:: D'EramoSat Jan 28 1989 19:466
     re .6
     
     It's too bad that the number 1729 shows up in your
     solutions.  It seems like such a dull, boring number.
     
     Dan
1016.8Hacker's delightPOOL::HALLYBThe smart money was on GoliathSun Jan 29 1989 07:174
>     It's too bad that the number 1729 shows up in your
>     solutions.  It seems like such a dull, boring number.
    
    Oh, I don't know.  I once rode in a cab with that number...
1016.9Dullness is in the brain of the beholderAKQJ10::YARBROUGHI prefer PiMon Jan 30 1989 16:319
re .7, .8; In case someone missed the point of this exchange, it's an "in" 
joke of sorts. The mathematician Hardy once visited the m'n Ramanujan in 
the hospital. H commented that the number of the taxi that delivered him 
was 1729. R remarked that that was a very interesting number, the smallest
integer that can be expressed as the sum of two cubes in two distinct ways
(1729 = 10^3+9^3 = 1^3+12^3). Hardy's comment later was that R seemed to 
have a personal aquaintance with each of the positive integers.

Lynn