All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Numbers
Find out (Posted on 2012-01-08) Difficulty: 3 of 5
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.)
Solution 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 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
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (13)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information