10
20
30
40
50 :
60 INPUT"How many digits? "N%
70 T%=TIME
80 L%=10*N%/3+1:DIMA%L%,B%N%:C%=B%
90 Z$="000000":T$="999999"
100 FORI%=1TOL%:A%?I%=2:NEXT
110 M%=0:P%=0
120 FORJ%=1TON%:Q%=0:K%=2*L%+1
130 FORI%=L%TO1STEP-1
140 K%=K%-2:X%=10*A%?I%+Q%*I%
150 Q%=X%DIVK%:A%?I%=X%-Q%*K%
160 NEXT
170 Y%=Q%DIV10:A%?1=Q%-10*Y%:Q%=Y%
180 IFQ%=9:M%=M%+1:GOTO220
190 IFQ%=10:$C%=STR$(P%+1)+LEFT$(Z$,M%):P%=0:GOTO210
200 $C%=STR$P%+LEFT$(T$,M%):P%=Q%
210 C%=C%+M%+1:M%=0
220 NEXT
230 $C%=STR$P%
240 T%=TIME-T%
250 IF N%<254:PRINT$B% ELSE FOR C%=0 TO N%:VDU B%?C%:NEXT:PRINT
260 PRINT T%;"cs"