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”).
%I #36 Apr 10 2022 09:18:40
%S 6,22,33,55,66,77,111,141,161,202,222,262,282,303,323,393,434,454,474,
%T 494,505,515,535,545,555,565,595,606,626,646,707,717,737,767,777,818,
%U 838,858,878,898,939,949,959,969,979,989,1001,1111,1221,1441,1551,1661
%N Squarefree composite palindromes.
%C Palindromes with at least two and all distinct prime factors.
%H Robert Israel, <a href="/A035134/b035134.txt">Table of n, a(n) for n = 1..10000</a>
%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/Squarefree.html">Squarefree</a>
%p N:= 4: # to get all terms with <= N digits
%p revdigs:= proc(n) local L, j, nL;
%p L:= convert(n, base, 10); nL:= nops(L);
%p add(L[j]*10^(nL-j), j=1..nL);
%p end proc:
%p palis:= $0..9:
%p for d from 2 to N do
%p if d::even then
%p palis:= palis, seq(x*10^(d/2)+revdigs(x), x=10^(d/2-1)..10^(d/2)-1)
%p else
%p 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);
%p fi
%p od:
%p select(t -> not(isprime(t)) and numtheory:-issqrfree(t), [palis][3..-1]): # _Robert Israel_, Sep 18 2016
%t 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 *)
%t Select[Range[2000],PalindromeQ[#]&&SquareFreeQ[#]&&CompositeQ[#]&] (* _Harvey P. Dale_, Apr 10 2022 *)
%o (PARI) isA002113(n)=n=digits(n);for(i=1, #n\2, if(n[i]!=n[#n+1-i], return(0))); 1;
%o is(n) = n>1 && isA002113(n) && issquarefree(n) && !isprime(n) \\ _Altug Alkan_, Sep 19 2016
%o \\ in and output digits as a vector.
%o (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])}
%o \\ all terms up to n digits
%o 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
%o (Python)
%o from itertools import product
%o from sympy import factorint, isprime
%o def pals(d, base=10): # all d-digit palindromes
%o digits = "".join(str(i) for i in range(base))
%o for p in product(digits, repeat=d//2):
%o if d > 1 and p[0] == "0": continue
%o left = "".join(p); right = left[::-1]
%o for mid in [[""], digits][d%2]: yield int(left + mid + right)
%o def ok(pal): f = factorint(pal); return len(f)>1 and all(f[p]<2 for p in f)
%o 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
%Y Cf. A002113, A005117, A035132, A035135.
%K nonn,base
%O 1,1
%A _Patrick De Geest_, Nov 15 1998