Substitute each of the capital letters by a different digit from 0 to 9 to satisfy this set of alphametic relationships. Each of A and R is nonzero.
(i) Each of RAISE and ARIES is a perfect square, and:
(ii) I + S and A + E are consecutive primes.
5 dim Used(9)
10 for R=1 to 9
20 Used(R)=1
30 for A=1 to 9
40 if Used(A)=0 then
50 :Used(A)=1
60 :for I=0 to 9
70 :if Used(I)=0 then
80 :Used(I)=1
90 :for E=0 to 9
100 :if Used(E)=0 then
110 :Used(E)=1
120 :for S=0 to 9
130 :if Used(S)=0 then
140 :Used(S)=1
200 :Raise=R*10000+A*1000+I*100+S*10+E
210 :Aries=A*10000+R*1000+I*100+E*10+S
220 :Sr=int(sqrt(Raise)+0.5)
230 :if Sr*Sr=Raise then
240 :Sr=int(sqrt(Aries)+0.5)
250 :if Sr*Sr=Aries then
260 :P1=I+S:P2=A+E
270 :if nxtprm(P1-1)=P1 and nxtprm(P1)=P2 then
280 :print Raise;Aries,int(sqrt(Raise)+0.5);int(sqrt(Aries)+0.5),P1;P2
290 :endif
300 :endif
320 :endif
450 :Used(S)=0
460 :endif
470 :next
480 :Used(E)=0
490 :endif
500 :next
510 :Used(I)=0
520 :endif
530 :next
540 :Used(A)=0
550 :endif
560 next
570 Used(R)=0
580 next
finds
square roots
------------
raise aries raise aries i+s a+e
18769 81796 137 286 13 17
|
Posted by Charlie
on 2010-04-16 16:35:41 |