Mr. X and Mr. Y live in the same avenue with only 9 houses between them. The number on their houses were both prime, and Mr. X found that he could express the number of his house as the sum of the squares of the digits of Mr. y's house number.
What were their house numbers ?
At first thought, with 9 houses between the two, Mr. Y's would be the 10th house over from Mr.X's on the same side of the street. That would imply their house numbers differed by 20 in the usual odd/even numbering system. However a search via computer program found no solution for primes differing by 20.
Then, assuming that the house numbers differ by 10, the program listed below finds two pairs of house numbers that work: x at 13, y at 23 or x at 73, y at 83.
The program is written in UBASIC:
20 while 1=1
40 if nxtprm(P2-1)=P2 then
60 :while T>0
100 :if P=DigSum then print P,P2:endif
160 :while T>0
200 :if P2=DigSum then print P,P2:endif
When the program was run with p2=p+20 instead of p2=p2+10, there were no results found. The program is manually stopped, and p in the millions when stopped.
Posted by Charlie
on 2003-12-02 10:36:36