%I #32 Jun 03 2024 03:47:11
%S 0,0,1,0,1,1,1,0,1,1,1,1,1,1,2,0,1,1,1,1,2,1,0,1,1,1,1,1,1,2,1,0,2,1,
%T 2,1,0,1,2,1,1,2,1,1,2,0,0,1,1,1,2,1,0,1,2,1,2,1,1,2,1,1,2,0,2,2,0,1,
%U 1,2,1,1,1,0,2,1,2,2,0,1,1,1,0,2,2,1,2,1,0,2,2,0,2,0,2,1,0,1,2,1,1,2,1,1,3,0,1,1,1,2
%N Number of twin prime (A001097) divisors of n.
%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/TwinPrimes.html">Twin Primes</a>.
%F G.f.: Sum_{k>=1} x^A001097(k)/(1 - x^A001097(k)).
%F a(A062729(n)) = 0. - _Ilya Gutkovskiy_, Apr 02 2017
%F From _Amiram Eldar_, Jun 03 2024: (Start)
%F a(A048599(n)) = n.
%F Asymptotic mean: Limit_{m->oo} (1/m) * Sum_{k=1..m} a(k) = A065421 - 1/5 = 1.7021605... . (End)
%e --------------------------------------------
%e | n | divisors of n | twin prime | a(n) |
%e | | | divisors of n | |
%e |------------------------------------------
%e | 1 | {1} | {-} | 0 |
%e | 2 | {1, 2} | {-} | 0 |
%e | 3 | {1, 3} | {3} | 1 |
%e | 4 | {1, 2, 4} | {-} | 0 |
%e | 5 | {1, 5} | {5} | 1 |
%e | 6 | {1, 2, 3, 6} | {3} | 1 |
%e | 7 | {1, 7} | {7} | 1 |
%e | 8 | {1, 2, 4, 8} | {-} | 0 |
%e | 9 | {1, 3, 9} | {3} | 1 |
%e --------------------------------------------
%t nmax = 110; Rest[CoefficientList[Series[Sum[Boole[PrimeQ[k] && (PrimeQ[k - 2] || PrimeQ[k + 2])] x^k/(1 - x^k), {k, 1, nmax}], {x, 0, nmax}], x]]
%t Table[Length[Select[Divisors[n], PrimeQ[#] && (PrimeQ[# - 2] || PrimeQ[# + 2]) &]], {n, 110}]
%o (PARI) concat([0, 0],Vec(sum(k=1, 110, (isprime(k) && (isprime(k - 2) || isprime(k + 2)))* x^k/(1 - x^k)) + O(x^111))) \\ _Indranil Ghosh_, Mar 22 2017
%o (PARI) a(n) = sumdiv(n, d, isprime(d) && (isprime(d-2) || isprime(d+2))); \\ _Amiram Eldar_, Jun 03 2024
%o (Python)
%o from sympy import isprime, divisors
%o print([len([i for i in divisors(n) if isprime(i) and (isprime(i - 2) or isprime(i + 2))]) for n in range(1, 111)]) # _Indranil Ghosh_, Mar 22 2017
%Y Cf. A001097, A001221, A005087, A062729, A065421, A284599.
%Y Cf. A048599 (positions of records).
%K nonn
%O 1,15
%A _Ilya Gutkovskiy_, Mar 22 2017