OFFSET
1,15
LINKS
Eric Weisstein's World of Mathematics, Twin Primes.
FORMULA
a(A062729(n)) = 0. - Ilya Gutkovskiy, Apr 02 2017
From Amiram Eldar, Jun 03 2024: (Start)
a(A048599(n)) = n.
Asymptotic mean: Limit_{m->oo} (1/m) * Sum_{k=1..m} a(k) = A065421 - 1/5 = 1.7021605... . (End)
EXAMPLE
--------------------------------------------
| n | divisors of n | twin prime | a(n) |
| | | divisors of n | |
|------------------------------------------
| 1 | {1} | {-} | 0 |
| 2 | {1, 2} | {-} | 0 |
| 3 | {1, 3} | {3} | 1 |
| 4 | {1, 2, 4} | {-} | 0 |
| 5 | {1, 5} | {5} | 1 |
| 6 | {1, 2, 3, 6} | {3} | 1 |
| 7 | {1, 7} | {7} | 1 |
| 8 | {1, 2, 4, 8} | {-} | 0 |
| 9 | {1, 3, 9} | {3} | 1 |
--------------------------------------------
MATHEMATICA
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]]
Table[Length[Select[Divisors[n], PrimeQ[#] && (PrimeQ[# - 2] || PrimeQ[# + 2]) &]], {n, 110}]
PROG
(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
(PARI) a(n) = sumdiv(n, d, isprime(d) && (isprime(d-2) || isprime(d+2))); \\ Amiram Eldar, Jun 03 2024
(Python)
from sympy import isprime, divisors
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
CROSSREFS
KEYWORD
nonn
AUTHOR
Ilya Gutkovskiy, Mar 22 2017
STATUS
approved