409 is an interesting prime number. If you remove any number of its digits, then you will get a number that is not prime.
4=2^2
0=not prime
9=3^2
40=2^3*5
49=7^2
09=9=3^2
Call a number with this property a minimal prime. Find all minimal primes.
This tests whether an input number is a minimal prime, and includes the single-digit primes:
10 repeat
20 input Tst:Tst=cutspc(str(Tst))
30 Pr=""
40 Good=1
50 if prmdiv(val(tst))<val(tst) then good=0:else gosub *Testing(1)
60 if Good then print "good":else print "bad"
65 until tst="0"
70 end
80
90 *Testing(Psn)
100 if Psn=len(Tst) then
110 :Prtst=val(Pr)
120 :if prmdiv(Prtst)=Prtst and Prtst<>0 and Prtst<>1 then Good=0:endif
130 :else
140 :gosub *Testing(Psn+1)
150 Pr=Pr+mid(Tst,Psn,1)
160 if Psn=len(Tst) and Psn>len(Pr) then
170 :Prtst=val(Pr)
180 :if prmdiv(Prtst)=Prtst and Prtst<>0 and Prtst<>1 then Good=0:endif
190 if Psn<len(Tst) then
200 :gosub *Testing(Psn+1)
205 pr=left(pr,len(pr)-1)
210 return
|
Posted by Charlie
on 2012-04-24 16:50:53 |