OFFSET
1,1
LINKS
Robert Israel, Table of n, a(n) for n = 1..10000
MAPLE
revdigs:= proc(n) local L, i;
L:= convert(n, base, 10);
add(L[-i]*10^(i-1), i=1..nops(L))
end proc:
f:= proc(n) local F;
F:= ifactors(n)[2];
if nops(F) = 2 and F[1, 2]=1 and F[2, 2]=1 then n fi
end proc:
N:=5: # for terms of up to N digits.
Res:= 6:
for d from 2 to N do
if d::even then
m:= d/2;
Res:= Res, seq(f(n*10^m + revdigs(n)), n=10^(m-1)..10^m-1);
else
m:= (d-1)/2;
Res:= Res, seq(seq(f(n*10^(m+1)+y*10^m+revdigs(n)), y=0..9), n=10^(m-1)..10^m-1);
fi
od:
Res; # Robert Israel, Mar 24 2020
MATHEMATICA
pdpfQ[n_]:=Module[{idn=IntegerDigits[n]}, idn==Reverse[idn] && PrimeNu[n] == PrimeOmega[n] == 2]; Select[Range[11000], pdpfQ] (* Harvey P. Dale, Dec 16 2012 *)
PROG
(Python)
from sympy import factorint
from itertools import product
def pals(d, base=10): # all d-digit palindromes
digits = "".join(str(i) for i in range(base))
for p in product(digits, repeat=d//2):
if d > 1 and p[0] == "0": continue
left = "".join(p); right = left[::-1]
for mid in [[""], digits][d%2]: yield int(left + mid + right)
def ok(pal): f = factorint(pal); return len(f) == 2 and sum(f.values()) == 2
print(list(filter(ok, (p for d in range(1, 5) for p in pals(d) if ok(p))))) # Michael S. Branicky, Jun 22 2021
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Patrick De Geest, Jun 15 1998
STATUS
approved