A348168 Segment the list of prime numbers into sublists L_1, L_2, ... with L_1 = {2} and L_n = {p_1, p_2, ..., p_a(n)}, where a(n) is the largest m such that for 0 < i < m, p_1 - prevprime(p_1) > p_2 - p_1 >= p_{i+1} - p_i.
1, 1, 1, 1, 2, 2, 1, 2, 4, 1, 2, 3, 2, 1, 6, 2, 2, 2, 1, 2, 1, 2, 2, 2, 1, 4, 2, 8, 1, 4, 2, 2, 1, 1, 5, 2, 1, 2, 2, 2, 1, 4, 6, 2, 2, 5, 8, 7, 2, 1, 1, 2, 10, 2, 2, 2, 2, 1, 4, 4, 2, 1, 5, 2, 1, 1, 2, 2, 2, 2, 1, 2, 2, 1, 4, 1, 1, 3, 2, 2, 3, 1, 2, 1, 2, 1, 2
Offset: 1
Examples
See also the table of the sublists in the examples for A362017. a(1) = 1 because L_1 = {2} by definition. In the following examples we use p_0 to denote prevprime(p_1). a(2) = 1. For the 2nd sublist, p_1 - p_0 = 3 - 2 = 1. If the next prime, 5, is in L_2, then p_2 - p_1 = 2 > p_1 - p_0. Therefore, 5 does not belong to L_2 and L_2 = {3}. a(5) = 2. For the 5th sublist, p_1 - p_0 = 11 - 7 = 4. p_2 = 13 is in L_5 because p_2 - p_1 = 2 < p_1 - p_0. However, the next prime, 17, is not in L_5 as 17 - 13 > p_2 - p_1. Thus, L_5 = {11, 13}. a(15) = 6. L_15 = {97, 101, 103, 107, 109, 113}, because p_1 - p_0 = 97-89 > p_2 - p_1 = 101-97 = 4, which is the maximum prime gap in L_15. 127, the prime after 113, is not in L_15 as 127-113 = 14 > p_2 - p_1.
Links
Programs
-
Python
from sympy import nextprime L = [2] for n in range(1, 100): print(len(L), end =', ') p0 = L[-1]; p1 = nextprime(p0); M = [p1]; g0 = p1 - p0; p = nextprime(p1); g1 = p - p1 while g1 < g0 and p - p1 <= g1: M.append(p); p1 = p; p = nextprime(p) L = M
Extensions
Edited by Peter Munn, Jul 08 2025
Comments