Explicit formula for the $n^{th}$ positive integer of a $p$-rough sequence A p-rough number, or p-jagged number, is an integer whose smallest prime factor is $p$ (Finch, 2001).
The
$3$-rough numbers are the odd numbers. The $7$-rough numbers are numbers not divisible by $2, 3,$ or $5,$ that is:
$ \left \{1, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 49, 53, 59, 61, 67, 71, ...\right \} $.

*

*I am struggling to find an explicit formula for the 7-rough numbers

*I also wonder whether there is some recurrence or other method that can be used to find the $n^{th}$ number of a $p$-rough sequence for any possible $p$.

Thanks in advance!

Edit
I found on OEIS the following formula by Gary Detlefs (Sep 15, 2013) for the $7$-rough numbers:
$$a(n) = \frac{6f(n) - 3 + (-1)^{f(n)}}{2}$$
where
$$f(n)= n + \lfloor\frac{n}{4}\rfloor + \lfloor\frac{(n+4) \mod 8}{6}\rfloor.$$
I wonder how it is derived and if it is possible to find an equivalent or alternative formula without the floor and mod operations in it.
 A: For the $7$-rough numbers, using $8$-th roots of unity
you can get
$$ a_n = \frac{15}4 n +
\frac18 (-15+ (1+i)i^n+(-1)^n+(1-i)(-i)^n) +\\
\frac18 i^{n/2}( ((1-3i)-(2+i)\sqrt{2}) +
((1+3i)+(2-i)\sqrt{2})i^n+\\ ((1-3i)+(2+i)\sqrt{2})(-1)^n + 
((1+3i)-(2-i)\sqrt{2})(-i)^n). $$
Noticing the period $8$ behavior it is only a matter of solving for the coefficients of the $8$th roots of unity. A similar
method would work for any specific $p$-rough sequence.
More explicitly, in general, the $p$-rough integer
sequence has a linear average behavior. Subtracting off
this linear function leaves a purely periodic sequence.
Any such sequence can be expressed as
$\,a_n=\sum_{k=0}^{N-1} c_k (\zeta^k)^n$ for some coefficients $c_k$
where $\zeta^k=e^{2\pi i k/N}$
are the $N$th roots of unity and where $N$ is the period.
The coefficients can be found by solving a system of
$N$ linear equations as in the
Discrete Fourier Transform.
In the case of $7$-rough, the linear function is
$\frac{15}4n$ and the remainder is a period $8$ sequence.
Notice that the $7$-rough numbers are all odd. Further,
$ (a(n+1) - a(n-1))/2$ is a bounded integer with
average value of $15/4$ and a period of $8$. Thus, a
good approximation is $a (n) \approx \lfloor 15n/4\rfloor.$
But this is always $\le 0$. A more balanced formula
is $a(n) = 3d(n) + e(n)$ where $d(n):=\lfloor 5n/4\rfloor,$ and $e(n+8)=e(n).$ We just have to find a formula for $e(n)$ which
depends only on $n \pmod 8$. The Detlefs formula is once such.
