|
!' 3797:素数 左から 3 37 379 3797,右から 7 97 797 3797
LET KMAX=10000
DIM A(KMAX)
LET A(1)=1
FOR I=2 TO KMAX
IF A(I)=0 THEN
FOR J=I*I TO KMAX STEP I
LET A(J)=1
NEXT J
END IF
NEXT I
FOR I=11 TO KMAX
IF A(I)=0 THEN
LET S$=STR$(I)
LET N=LEN(S$)
LET FL=0
FOR J=1 TO N-1
LET L=VAL(LEFT$(S$,J))
LET R=VAL(RIGHT$(S$,J))
IF A(L)<>0 OR A(R)<>0 THEN
LET FL=1
EXIT FOR
END IF
NEXT J
IF FL=0 THEN PRINT I
END IF
NEXT I
END
|
|