5 A=100:open "8primes.txt" for output as #2
10 while A<1000
20 A=nxtprm(A)
30 if A<1000 and (A\10)@10>0 then
35 :B=100
40 :while B<1000
50 :B=nxtprm(B)
60 :if B<1000 then
70 :C=100
80 :while C<1000
90 :C=nxtprm(C)
100 :Av=100*(A\100)+10*(B\100)+C\100
110 :Bv=100*((A\10)@10)+10*((B\10)@10)+((C\10)@10)
130 :Cv=100*(A@10)+10*(B@10)+C@10
140 :D1=100*(A\100)+10*((B\10)@10)+C@10
150 :D2=100*(A@10)+10*((B\10)@10)+C\100
160 :if prmdiv(Av)=Av and prmdiv(Bv)=Bv and prmdiv(Cv)=Cv then
170 :if prmdiv(D1)=D1 and prmdiv(D2)=D2 then
180 :print #2,A;B;C,Av;Bv;Cv
190 :inc Solct
200 :endif
210 :endif
220 :wend
230 :endif
240 :wend
250 :endif
260 wend
270 print Solct
finds 6825 ways of arranging it so that all 8 specified lines contain 3-digit primes, not necessarily unique.
If all 8 primes are different, you cannot use just two different digits repeated to form the square. The most different primes present is five for this purpose:
311
113
331
313
113
131
313
311
131
313
313
131
331
113
311
331
113
331
911
199
911
911
199
991
Symmetry about the diagonals is possible replicating just three unique digits, and in a couple of cases, just two:
Three unique digits:
113
151
311
113
181
311
131
353
131
131
383
131
151
599
191
151
599
199
181
883
131
191
991
113
191
997
179
193
911
313
197
991
719
211
131
113
223
211
311
227
223
733
227
227
773
227
229
797
229
211
911
229
227
977
229
229
997
233
311
311
233
313
331
233
373
337
277
727
773
311
139
191
311
151
113
311
181
113
Two unique digits:
313
113
331
911
199
191
Symmetry about the other diagonal (some about both diagonals; all with 3 unique digits repeated as necessary):
113
151
311
113
181
311
131
353
131
131
383
131
191
199
311
311
151
113
311
181
113
313
151
313
313
181
313
313
311
733
337
353
733
337
383
733
373
757
373
373
787
373
733
353
337
733
383
337
797
929
797
Third criterion:
Some of the below use fewer than five different digits, but those with five different digits are included as well and are marked with an *:
223
211
311
223 *
241
911
223
251
311
223 *
251
911
223
271
311
223 *
271
911
223
281
311
223 *
281
911
227
223
733
227
283
733
227
293
733
229
211
911
229
227
977
229 *
251
311
229 *
281
311
331
359
199
331
389
199
449
421
911
557
523
733
557
593
733
661
659
199
773
751
311
881
809
199
881
839
199
881
859
199
883
811
311
883
881
311
887
823
733
887
853
733
887
883
733
997
953
733
997
983
733
|
Posted by Charlie
on 2013-10-09 18:06:22 |