login
Smallest palindromic prime with digit sum = n, or 0 if no such prime exists.
2

%I #7 Dec 10 2015 09:27:59

%S 0,2,3,0,5,0,7,10601,0,181,191,0,373,383,0,727,13931,0,757,929,0,787,

%T 797,0,17971,39293,0,19891,19991,0,77377,76667,0,78487,79397,0,77977,

%U 78887,0,97879,79997,0,1987891,1988891,0,1998991,3799973,0,3899983

%N Smallest palindromic prime with digit sum = n, or 0 if no such prime exists.

%C a(3k) = 0 for k>1 because if the digital sum is equal to a multiple of 3, then the number is divisible by 3. a(4) = 0 because any palindromic number whose digital sum is 4 is divisible by a number of the form 10^k + 1 for some k.

%H Chai Wah Wu, <a href="/A070245/b070245.txt">Table of n, a(n) for n = 1..150</a>

%t a = Table[0, {75}]; Do[p = IntegerDigits[Prime[n]]; If[ Reverse[p] == p, q = Plus @ @ p; If[ a[[q]] == 0 && q < 76, a[[q]] = FromDigits[p]]], {n, 1, 10^7}]

%Y Cf. A002385.

%K base,nonn

%O 1,2

%A _Amarnath Murthy_, May 05 2002

%E Edited, corrected and extended by _Robert G. Wilson v_, May 06 2002