What palindromic prime number of n digits reads the same upside down or when viewed in a mirror?
Some examples for n=2 or 3:
11, 101, 181.
How far can you go?
Rem: Only digits 0,l and 8 qualify.
(In reply to
computer solution by Charlie)
length count
3 2
5 1
7 4
9 12
11 26
13 62
15 173
17 392
19 1087
21 3197
23 8189
25 23354
Later, to compare expected numbers to the above:
There are 3^((n-1)/2) possible n-digit palindromes formed with 1, 0 and 8 that begin and end with 1.
An approximation to the number of prime numbers with n digits is 10^n/ln(10^n) - 10^(n-1)/ln(10^(n-1)) = 10^n/(ln(10)*n) - 10^(n-1)/(ln(10)*(n-1)), and this is out of 10^n such numbers, so the fraction of numbers of this length that are prime would be approximated by 1/(ln(10)*n) - 1/(10*ln(10)*n).
Multiplying this fraction by the number of palindromes, the result is 3^((n-1)/2)*(1/(ln(10)*n) - 1/(10*ln(10)*n)).
The expected number in each length category is then (rounded to an integer):
3 0
5 1
7 2
9 4
11 9
13 22
15 57
17 151
19 405
21 1099
23 3010
25 8309
27 23080
DEFDBL A-Z
FOR n = 3 TO 27 STEP 2
PRINT n,
expected = 3 ^ ((n - 1) / 2) * (1 / (LOG(10#) * n) - 1 / (10 * LOG(10#) * n))
expected = INT(expected + .5)
PRINT expected
NEXT
Edited on May 4, 2012, 5:24 pm
|
Posted by Charlie
on 2012-05-04 16:39:02 |