All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars
 Click to listen to the single ▶Support album on Kickstarter perplexus dot info

 Find out (Posted on 2012-01-08)
How many k-digit palindromes are prime?
Please solve for k=1,2,3, ... 9.

 No Solution Yet Submitted by Ady TZIDON No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
 computer solution | Comment 1 of 2

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 palindromes1       42       13       154       05       936       07       6688       09       517210      011      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

 Search: Search body:
Forums (0)