login
Sum of twin prime (A001097) divisors of n.
2

%I #19 May 09 2021 11:19:02

%S 0,0,3,0,5,3,7,0,3,5,11,3,13,7,8,0,17,3,19,5,10,11,0,3,5,13,3,7,29,8,

%T 31,0,14,17,12,3,0,19,16,5,41,10,43,11,8,0,0,3,7,5,20,13,0,3,16,7,22,

%U 29,59,8,61,31,10,0,18,14,0,17,3,12,71,3,73,0,8,19,18,16,0,5,3,41,0,10,22,43,32,11,0,8

%N Sum of twin prime (A001097) divisors of n.

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

%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/TwinPrimes.html">Twin Primes</a>

%H <a href="/index/Su#sums_of_divisors">Index entries for sequences related to sums of divisors</a>

%F G.f.: Sum_{k>=1} A001097(k)*x^A001097(k)/(1 - x^A001097(k)).

%F a(n) = Sum_{d|n, d twin prime} d.

%F a(A062729(n)) = 0.

%F a(A001097(n)) = A001097(n).

%e a(15) = 8 because 15 has 4 divisors {1, 3, 5, 15} among which 2 are twin primes {3, 5} therefore 3 + 5 = 8.

%p N:= 200: # to get a(1)..a(N)

%p P:= select(isprime, {seq(i,i=3..N+2)}):

%p TP:= P intersect map(`-`,P,2):

%p TP:= TP union map(`+`,TP,2):

%p V:= Vector(N):

%p for p in TP do

%p pm:= [seq(i,i=p..N,p)];

%p V[pm]:= map(`+`,V[pm],p);

%p od:

%p convert(V,list); # _Robert Israel_, Mar 30 2017

%t Table[Total[Select[Divisors[n], PrimeQ[#1] && (PrimeQ[#1 - 2] || PrimeQ[#1 + 2]) &]], {n, 80}]

%o (Python)

%o from sympy import divisors, isprime

%o def a(n): return sum([i for i in divisors(n) if isprime(i) and (isprime(i - 2) or isprime(i + 2))])

%o print([a(n) for n in range(1, 91)]) # _Indranil Ghosh_, Mar 30 2017

%o (PARI) a(n) = sumdiv(n, d, d*(isprime(d) && (isprime(d-2) || isprime(d+2)))); \\ _Michel Marcus_, Apr 02 2017

%Y Cf. A001097, A008472, A062729, A284203.

%K nonn

%O 1,3

%A _Ilya Gutkovskiy_, Mar 30 2017