login
Number of base reversals which result in a prime for bases less than n.
0

%I #15 Apr 29 2021 04:11:15

%S 0,0,1,0,3,2,5,2,1,3,7,3,10,4,3,3,12,4,9,5,4,7,14,4,11,5,5,7,15,3,20,

%T 9,6,6,12,3,19,11,9,6,23,4,26,8,6,10,24,7,17,11,7,15,33,4,19,9,12,12,

%U 22,5,30,16,11,13,15,4,38,15,14,8,36,5,40,17,7,13,32,4,39,13,6,13,38,4,25

%N Number of base reversals which result in a prime for bases less than n.

%C If n is composite, then there does not exist any base greater than n whose base reversal is prime. And if n is a prime, then there exist an infinite number of bases greater than n whose base reversals are primes (hence this sequence's restriction to bases up to n only).

%e a(5) = 3 because 5 = 101_2 and its reversal 101_2 = 5, 5 = 12_3 and its reversal 21_3 = 7, 5 = 11_4 and its reversal 11_4 = 5. 3, 7, and 5 are all primes.

%t a[n_] := Block[{c = 0, b = 2}, While[b < n + 1, If[ PrimeQ[ FromDigits[ Reverse[ IntegerDigits[n, b]], b]], c++ ]; b++ ]; c]; Table[ a[n], {n, 1, 85}]

%o (PARI) a(n) = sum(b=2, n-1, isprime(fromdigits(Vecrev(digits(n, b)), b))); \\ _Michel Marcus_, Apr 29 2021

%K base,easy,nonn

%O 1,5

%A _Robert G. Wilson v_, Sep 09 2002