login
Palindromes (A002113) in A157037.
1

%I #19 May 09 2023 08:56:21

%S 6,22,66,202,222,282,434,454,474,494,555,595,838,858,969,1001,1551,

%T 1771,3333,3553,5335,6006,6226,6886,8778,9889,12921,14541,15051,16261,

%U 16761,17171,18681,19491,20202,20602,20802,20902,24142,24242,24542,28282,28482,30003

%N Palindromes (A002113) in A157037.

%C Intersection of A002113 and A157037.

%H Robert Israel, <a href="/A353703/b353703.txt">Table of n, a(n) for n = 1..10000</a>

%e 22 = A002113(12) and 22 = A157037(3), so 22 is a term.

%e 66 = A002113(16) and 22 = A157037(8), so 66 is a term.

%p filter:= proc(n) local t;

%p isprime(n*add(t[2]/t[1], t=ifactors(n)[2]))

%p end proc:

%p digrev:= proc(n) local L,i;

%p L:= convert(n,base,10);

%p add(L[-i]*10^(i-1),i=1..nops(L))

%p end proc:

%p N:= 100: # for a(1) to a(N)

%p Res:= 6: count:= 1:

%p for d from 2 while count < N do

%p if d::even then

%p m:= d/2;

%p for n from 10^(m-1) to 10^m-1 while count < N do

%p v:= n*10^m + digrev(n);

%p if filter(v) then Res:= Res,v; count:= count+1 fi;

%p od

%p else

%p m:= (d-1)/2;

%p for n from 10^(m-1) to 10^m-1 while count < N do

%p for y from 0 to 9 while count < N do

%p v:= n*10^(m+1)+y*10^m+digrev(n);

%p if filter(v) then Res:= Res,v; count:= count+1 fi;

%p od od:

%p fi

%p od:

%p Res; # _Robert Israel_, May 09 2023

%t d[0] = d[1] = 0; d[n_] := n * Plus @@ ((Last[#]/First[#]) & /@ FactorInteger[n]); Select[Range[30003], PalindromeQ[#] && PrimeQ[d[#]] &] (* _Amiram Eldar_, May 09 2022 *)

%o (Magma) f:=func<n |n le 1 select 0 else n*(&+[Factorisation(n)[i][2] / Factorisation(n)[i][1]: i in [1..#Factorisation(n)]])>; pal:=func<n|Intseq(n) eq Reverse(Intseq(n))>; [n:n in [2..30003]| pal(n) and IsPrime(Floor(f(n)))];

%o (PARI) ad(n) = vecsum([n/f[1]*f[2]|f<-factor(n+!n)~]); \\ A003415

%o isok(m) = my(d); isprime(ad(m)) && (d=digits(m)) && (d==Vecrev(d)); \\ _Michel Marcus_, May 09 2022

%o (Python)

%o from itertools import chain, count, islice

%o from sympy import isprime, factorint

%o def A353703_gen(): # generator of terms

%o return filter(lambda n:isprime(sum(n*e//p for p,e in factorint(n).items())), chain.from_iterable(chain((int((s:=str(d))+s[-2::-1]) for d in range(10**l,10**(l+1))), (int((s:=str(d))+s[::-1]) for d in range(10**l,10**(l+1)))) for l in count(0)))

%o A353703_list = list(islice(A353703_gen(),20)) # _Chai Wah Wu_, Jun 23 2022

%Y Cf. A002113, A003415, A157037.

%K nonn,base

%O 1,1

%A _Marius A. Burtea_, May 08 2022