login
A372629
Prime numbers whose sum of digits is a palindrome.
1
2, 3, 5, 7, 11, 13, 17, 23, 29, 31, 41, 43, 47, 53, 61, 71, 83, 101, 103, 107, 113, 131, 137, 151, 173, 191, 211, 223, 227, 233, 241, 251, 263, 281, 311, 313, 317, 331, 353, 401, 421, 431, 443, 461, 499, 503, 521, 601, 641, 701, 769, 787, 821, 859, 877, 911, 967, 1013, 1019, 1021, 1031, 1033, 1051
OFFSET
1,1
LINKS
Paolo Xausa, Table of n, a(n) for n = 1..10000 (terms 1..999 from James S. DeArmon)
EXAMPLE
2411 is a term (prime, and digits sum to 8, a palindrome);
9931 is a term (prime, and digits sum to 22, a palindrome);
10099997 is a term (prime, and digits sum to 44).
MATHEMATICA
Select[Prime[Range[200]], PalindromeQ[DigitSum[#]] &] (* Paolo Xausa, Feb 27 2025 *)
PROG
(Python)
import sympy
def sum_of_digits(n):
return sum(int(digit) for digit in str(n))
def is_palindrome(n):
return str(n) == str(n)[::-1]
# Find prime numbers between 1 and 10000 whose sum of digits is a palindrome
prime_palindrome_numbers = []
for num in range(1, 10000):
if sympy.isprime(num):
digit_sum = sum_of_digits(num)
if is_palindrome(digit_sum):
prime_palindrome_numbers.append(num)
print(prime_palindrome_numbers)
(Python)
from sympy import isprime
def ok(n): return isprime(n) and (s:=str(sum(map(int, str(n))))) == s[::-1]
print([k for k in range(1100) if ok(k)]) # Michael S. Branicky, Oct 02 2025
(Common Lisp) ; See Links section.
CROSSREFS
KEYWORD
nonn,base,less
AUTHOR
James S. DeArmon, May 07 2024
STATUS
approved