Step 1: Generate Sequences A and B
Generate the sequences 𝐴 = 6𝑘 − 1 and 𝐵 = 6𝑘 + 1 up to a limit. Let’s choose a limit of 𝑘 = 10 for illustration.
For simplicity in this example, we’ll use values of 𝐴 AND 𝐵, rather than a symmetrical range implementation for |𝐴| OR |𝐵| using absolute values I believe is more efficient and elegant.
k step | A (6k-1) | B (6k+1) |
0 | -1 | 1 |
1 | 5 | 7 |
2 | 11 | 13 |
3 | 17 | 19 |
4 | 23 | 25 |
5 | 29 | 31 |
6 | 35 | 37 |
7 | 41 | 43 |
8 | 47 | 49 |
9 | 53 | 55 |
10 | 59 | 61 |
Step 2: Identify Primes Using a Sieve-like Method
Primes in 𝐴 and 𝐵 are those numbers that are not divisible by any smaller prime. For simplicity, assume we have already identified primes up to a certain limit:
Prime Sequence | Numbers | Primes |
A | 5, 11, 17, 23, 29, 35, 41, 47, 53, 59 | 5, 11, 17, 23, 29, 41, 47, 53, 59 |
B | 7, 13, 19, 25, 31, 37, 43, 49, 55, 61 | 7, 13, 19, 31, 37, 43, 61 |
Step 3: Initialize Min-Heap for Composite Numbers
We start by squaring the primes and inserting them into a min-heap. This table tracks the current state of the heap.
BPN Index Step | Numerical Form | Initial Composite | Heap State |
1 | 5 | 5 * 5 = 25 | 25 |
2 | 7 | 7 * 7 = 49 | 25, 49 |
3 | 11 | 11 * 11 = 121 | 25, 49, 121 |
4 | 13 | 13 * 13 = 169 | 25, 49, 121, 169 |
5 | 17 | 17 * 17 = 289 | 25, 49, 121, 169, 289 |
6 | 19 | 19 * 19 = 361 | 25, 49, 121, 169, 289, 361 |
… | … | … | … |
Step 4: Generate and Track Composite Numbers
Here we extract the smallest composite, generate new composites, and update the heap.
Extracted Composite | New Composites Generated | Updated Heap State |
25 (5*5) | 5 * 7 = 35, 5 * 11 = 55 | 35, 49, 121, 169, 289, 361, 55 |
35 (5*7) | 5 * 13 = 65, 7 * 7 = 49 | 49, 49, 121, 169, 289, 361, 55, 65 |
49 (7*7) | 7 * 11 = 77, 11 * 11 = 121 | 49, 55, 121, 169, 289, 361, 65, 77 |
55 (5*11) | 5 * 17 = 85, 11 * 13 = 143 | 65, 77, 121, 143, 169, 289, 361, 85 |
… | … | … |
Step 5: Infer Prime Numbers
Index values that do not produce matching composite values are inferred as primes.
BPN Index | Absolute Value | Composite | Prime? |
0 | 1 | No | No |
1 | 5 | No | Yes |
2 | 7 | No | Yes |
3 | 11 | No | Yes |
4 | 13 | No | Yes |
5 | 17 | No | Yes |
6 | 19 | No | Yes |
7 | 23 | No | Yes |
8 | 25 | Yes | No |
9 | 29 | No | Yes |
10 | 31 | No | Yes |
11 | 35 | Yes | No |
12 | 37 | No | Yes |
13 | 41 | No | Yes |
14 | 43 | No | Yes |
15 | 47 | No | Yes |
16 | 49 | Yes | No |
17 | 53 | No | Yes |
18 | 55 | Yes | No |
19 | 59 | No | Yes |
20 | 61 | No | Yes |
Summary
This table-based method helps to visualize and systematically identify composites within the BPN framework. By using sequences 𝐴 and 𝐵, initializing a heap with prime squares, and tracking generated composites, we can efficiently infer primes based on indices that do not produce composite values.
Levity
Q: Why did the algorithm developer wonder if he could swap piles
for
?heaps
A: Because managing those composite
elements was a real pain for his backend.