Each of the capital letters in bold denotes a different base ten digit from 1 to 9 in this cryptarithmetic expression:
AB/C + DE/F + GH/I
(I) Determine the respective smallest and the largest positive integer that this expression can assume.
(II) Determine the respective smallest and the largest prime number that this expression can assume. What are the respective smallest and the largest palindrome assumed by the above expression?
5 point 9
10 S$="123456789":H$=S$
15 Highval=0:Lowval=999999999999999:Highprime=0:Lowprime=99999999999999
16 Highpal=0:Lowpal=999999999999999
20 repeat
30 gosub *Permute(&S$)
40 Abc=val(mid(S$,1,1))^(val(mid(S$,2,1))/val(mid(S$,3,1)))
41 Def=val(mid(S$,4,1))^(val(mid(S$,5,1))/val(mid(S$,6,1)))
42 Ghi=val(mid(S$,7,1))^(val(mid(S$,8,1))/val(mid(S$,9,1)))
50 Sum=Abc+Def+Ghi
60 if abs(Sum-int(Sum+0.5))<0.000000000000001 then
65 :Sum=int(Sum+0.5)
70 :if Sum>Highval then Highval=Sum:Highstr=S$:endif
75 :if Sum<Lowval then Lowval=Sum:Lowstr=S$:endif
80 :if prmdiv(Sum)=Sum and Sum>Highprime then Highprime=Sum:Highpr
str=S$:endif
85 :if prmdiv(Sum)=Sum and Sum<Lowprime then Lowprime=Sum:Lowprstr
=S$:endif
90 :if prmdiv(Sum)=0 then print "***";Sum;S$:endif
400 until S$=H$
700 print Lowstr,Lowval:print Highstr,Highval:print
710 print Lowprstr,Lowprime:print Highprstr,Highprime:print
799 end
800
900 *Permute(&A$)
finds:
157263948 8
472563891 134217881
157293846 13
542781963 5764907
Translated that's:
1^(5/7)+2^(6/3)+9^(4/8) = 8
4^(7/2)+5^(6/3)+8^(9/1) = 134,217,881
1^(5/7)+2^(9/3)+8^(4/6) = 13
5^(4/2)+7^(8/1)+9^(6/3) = 5,764,907
Does 8 count as a palindrome?
|
Posted by Charlie
on 2010-12-04 18:26:37 |