What is the formula for the nth number in this series. $1,3,7,9,11,13,17,19,21\dots$
Basically all the numbers that end in the digits $1,3,7,9$
I am working on a formula for approximating how many factors I have to test to find if a large number is prime. So for example to test the number $229,597$. How many possible factors will I have to check?
So the convention is to take the square root of $229,597$ which is approx $479$. Then I take $(\frac{479}{10}) \times (4) - 1$. I do this because out of every ten numbers there are 4 numbers that end in $1,3,7,9$. I subtract the 1 because prime numbers also have 1 as a factor.
So   $(\frac{479}{10}) \times (4) - 1  = 190$ factors to check to see if $229,597$ is prime.
Then I look at the series $1,3,7,9,11,13,17\dots$ to start checking for possible factors. But how do I find the nth number in this series?

One possible formula is $$f(n) = \frac{1}{4}\left(5(2n-1) + (-1)^{n+1} + 2 \cos \frac{n \pi}{2} - 2 \sin \frac{n \pi}{2}\right), \quad n = 1, 2, \ldots.$$  This corresponds to the recurrence relation
$$\begin{align}
f(n) &= f(n-1) + f(n-4) - f(n-5), \\
f(1) &= 1, \\
f(2) &= 3, \\
f(3) &= 7, \\
f(4) &= 9, \\
f(5) &= 11.
\end{align}$$
I don't know why you would need it, though.
