10 for K=1 to 11
20 Half=-int(-K/2)
30 Min=10^(Half-1)
40 Max=10^Half-1
50 Primct=0
60 for N=Min to Max
70 Ns=cutspc(str(N))
80 Back=""
90 for I=1 to int(K/2)
100 Back=mid(Ns,I,1)+Back
110 next I
120 Pal=val(Ns+Back)
130 if prmdiv(Pal)=Pal and Pal<>1 then inc Primct
140 next N
150 print K,Primct
160 next K
k number of prime palindromes
1 4
2 1
3 15
4 0
5 93
6 0
7 668
8 0
9 5172
10 0
11 7871
All palindromes with an even number of digits are divisible by 11, so 11 itself is the only such prime, which of course falls into the k=2 count.
|
Posted by Charlie
on 2012-01-08 13:16:39 |