A242459 Maximal differences of A029707.
1, 2, 3, 4, 6, 12, 20, 24, 27, 29, 42, 54, 72, 75, 103, 128, 131, 151, 153, 162, 164, 181, 204, 208, 209, 211, 237, 265, 285, 286, 326, 335, 340, 356, 368, 392, 409, 432, 439, 441, 444, 446
Offset: 1
Programs
-
Mathematica
nextLesserTwinPrime[p_Integer] := Block[{q = p + 2}, While[ NextPrime@ q - q > 2, q = NextPrime@ q]; q]; p = 2; q = 3; px = 1; qx = 2; mxd = 0; tpx = 0; lst = {}; While[p < 5090000001, d = qx - px; If[ d > mxd, mxd = d; AppendTo[ lst, d]; Print@ d]; p = q; px = qx; q = nextLesserTwinPrime@ q; qx = PrimePi@ q; tpx++]; lst (* Robert G. Wilson v, May 21 2014 *)
-
Sage
def A242459_list(n) : a = [ 1 ] st = 3 for i in (4..n) : if (nth_prime(i+1)-nth_prime(i) == 2) : if i-st > a[len(a)-1] : a.append(i-st) st = i return(a) A242459_list(10^(5))
Formula
a(n) = primepi(next(A054691(n-1))) - primepi(A054691(n-1)) + 1 for n >= 2, where primepi = A000720 and next(k) is the least lesser of twin primes that is larger than k. - Amiram Eldar, May 19 2024
Extensions
a(20)-a(28) from Robert G. Wilson v, May 21 2014
a(29)-a(42) from Amiram Eldar, May 19 2024