login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A035134
Squarefree composite palindromes.
2
6, 22, 33, 55, 66, 77, 111, 141, 161, 202, 222, 262, 282, 303, 323, 393, 434, 454, 474, 494, 505, 515, 535, 545, 555, 565, 595, 606, 626, 646, 707, 717, 737, 767, 777, 818, 838, 858, 878, 898, 939, 949, 959, 969, 979, 989, 1001, 1111, 1221, 1441, 1551, 1661
OFFSET
1,1
COMMENTS
Palindromes with at least two and all distinct prime factors.
LINKS
Eric Weisstein's World of Mathematics, Squarefree
MAPLE
N:= 4: # to get all terms with <= N digits
revdigs:= proc(n) local L, j, nL;
L:= convert(n, base, 10); nL:= nops(L);
add(L[j]*10^(nL-j), j=1..nL);
end proc:
palis:= $0..9:
for d from 2 to N do
if d::even then
palis:= palis, seq(x*10^(d/2)+revdigs(x), x=10^(d/2-1)..10^(d/2)-1)
else
palis:= palis, seq(seq(x*10^((d+1)/2)+y*10^((d-1)/2)+revdigs(x), y=0..9), x=10^((d-3)/2)..10^((d-1)/2)-1);
fi
od:
select(t -> not(isprime(t)) and numtheory:-issqrfree(t), [palis][3..-1]): # Robert Israel, Sep 18 2016
MATHEMATICA
sqfQ[n_]:=Max[Transpose[FactorInteger[n]][[2]]]<=1; palQ[n_]:=FromDigits[Reverse[IntegerDigits[n]]]==n; Select[Range[2, 1662], !PrimeQ[#] && sqfQ[#] && palQ[#] &] (* Jayanta Basu, May 12 2013 *)
Select[Range[2000], PalindromeQ[#]&&SquareFreeQ[#]&&CompositeQ[#]&] (* Harvey P. Dale, Apr 10 2022 *)
PROG
(PARI) isA002113(n)=n=digits(n); for(i=1, #n\2, if(n[i]!=n[#n+1-i], return(0))); 1;
is(n) = n>1 && isA002113(n) && issquarefree(n) && !isprime(n) \\ Altug Alkan, Sep 19 2016
\\ in and output digits as a vector.
(PARI) nxtA002113(n)={my(d=n); i=(#d+1)\2; while(i&&d[i]==9, d[i]=0; d[#d+1-i]=0; i--); if(i, d[i]++; d[#d+1-i]=d[i], d=vector(#d+1); d[1]=d[#d]=1); d}\\sum(i=1, #d, 10^(#d-i)*d[i])}
\\ all terms up to n digits
lista(n) = {my(p = [6], l=List(), sp, i); while(#p <= n, sp = sum(i=1, #p, p[i]*10^(#p-i)); if(issquarefree(sp)&&!isprime(sp), listput(l, sp)); p=nxtA002113(p)); l} \\ David A. Corneth, Sep 19 2016
(Python)
from itertools import product
from sympy import factorint, isprime
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)>1 and all(f[p]<2 for p in f)
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, Nov 15 1998
STATUS
approved