Three 3-digit primes, all digits being distinct, sum up to a three digit number.
Can you find this number?
Please provide answers to two distinct versions of the problem:
a. No zeroes allowed .
b. Zeroes, non-leading of course, can appear on both sides of the equation.
10 A=99
20 repeat
30 A=nxtprm(A):Aa=cutspc(str(A))
40 Good=1
50 for I=1 to 2
60 if instr(mid(Aa,I+1,*),mid(Aa,I,1))>0 then Good=0
70 next I
80 if Good then
110 :B=A
120 :repeat
130 :B=nxtprm(B):Bb=cutspc(str(B))
140 :Good=1
145 :if instr(Aa,mid(Bb,3,1))>0 then Good=0:endif
150 :for I=1 to 2
160 :if instr(mid(Bb,I+1,*)+Aa,mid(Bb,I,1))>0 then Good=0:endif
170 :next I
180 :if Good then
210 :C=B
220 :repeat
230 :C=nxtprm(C):Cc=cutspc(str(C))
240 :Good=1
245 :if instr(Aa+Bb,mid(Cc,3,1))>0 then Good=0:endif
250 :for I=1 to 2
260 :if instr(mid(Cc,I+1,*)+Aa+Bb,mid(Cc,I,1))>0 then Good=0:endif
270 :next I
280 :if Good and A+B+C<1000 then print A;B;C,A+B+C:Ct=Ct+1:endif
310 :until C>999
320 :endif
330 :until B>999
340 :endif
350 until A>999
400 print Ct
produces
primes sum
103 269 457 829
103 269 487 859
103 269 547 919
103 269 587 959
107 283 569 959
109 257 463 829
109 263 457 829
109 263 487 859
109 263 547 919
109 263 587 959
109 283 457 849
109 283 467 859
109 283 547 939
149 263 587 999
157 263 409 829
157 283 409 849
163 257 409 829
167 283 409 859
167 283 509 959
of which only 149 + 263 + 587 = 999 lacks a zero.
|
Posted by Charlie
on 2010-09-11 16:22:45 |