Let $f(n)$ be the nth number of the form $6k\pm1$, which can be defined by $f(n) = 3n + \frac{3}{2} - \frac{(-1)^n}{2}$.
Now $f(n)$ obviously outputs all primes $p \gt3$, but also composite numbers whose factors were previously given by $f(n)$. (In other words, a composite number produced by $f(n)$ never has 2 or 3 as a factor.)
A way of avoiding these composites is based on a growing set of simple modulo-rules and the previous outputs of $f(n)$:
Given $f(n) = a$, where $a$ is prime, every following input $n^*$ which satisfies $n^* \equiv n\pmod{2a}$ or $n^* \equiv b_n\pmod{2a}$ will output a composite with $a$ as a factor, where $b_n$ is the nth element of the sequence $\{8,11,18,21,28,31,38,41,48,...\}$
(Please bear with me, I'm afraid this part is a bit confusing to get across, so I'll give with some examples)
- $f(1) = 5$, so every following $n$ which is $\equiv 1\pmod{10}$ or $\equiv 8\pmod{10}$ will produce a composite with 5 as a factor.
- $f(2) = 7$, so every following $n$ which is $\equiv 2\pmod{14}$ or $\equiv 11\pmod{14}$ will produce a composite with 7 as a factor.
- $f(3) = 11$, so every following $n$ which is $\equiv 3\pmod{22}$ or $\equiv 18\pmod{22}$ will produce a composite with 11 as a factor.
- $f(4) = 13$, so every following $n$ which is $\equiv 4\pmod{26}$ or $\equiv 21\pmod{26}$ will produce a composite with 13 as a factor.
My main question is: Is this an efficient type of sieve? Because it knows no upper bounds, outputs every prime $p\gt3$ without skipping any and the next input is given by a set of modulo-rules, which should be fast to compute.
My side question is: Is it possible to derive a fomula for every modulo-rule like $f(n)$ for $6k\pm1$? (With that I mean to create a formula which outputs all numbers which satisfy the rule)