list
10 dim Dig(10)
20 Strt=-int(-sqrt(11^9))
30 Fin=int(sqrt(11^10-1))
40 for Root=Strt to Fin
50 Sq=Root*Root
60 for I=0 to 9
70 Dig(I)=Sq @ 11
80 Sq=Sq\11
90 next I
100 N1=0
110 for I=9 to 5 step -1
120 N1=N1*11+Dig(I)
130 next I
140 N2=0
150 for I=4 to 0 step -1
160 N2=N2*11+Dig(I)
170 next I
180 if N2=N1+1 then print Root*Root
185 :for I=9 to 0 step -1:print Dig(I);:if I=5 then print " ";:endif
186 :next:print
190 next Root
200 print:print Fin-Strt+1
OK
run
2881864489
1 2 4 9 8 1 2 4 9 9
6484275625
2 8 2 8 2 2 8 2 8 3
6484597729
2 8 2 8 4 2 8 2 8 5
11528102161
4 9 8 6 3 4 9 8 6 4
18012055681
7 7 0 3 3 7 7 0 3 4
112492
OK
shows that 5 of the 112,492 perfect squares in the given range satisfy the condition, so the probability is 5/112,492.
The table printed shows the decimal representation of the square, followed by the base-11 representation. The middle of the latter is spaced farther than the other digits to highlight the two separate parts asked for by the puzzle.
|
Posted by Charlie
on 2010-09-10 14:16:29 |