# Need this Function Explained

I'm working on a personal project and I did a search for an integer sequence on the site listed below. I found the sequence I was looking for with a short description of the function defining the sequence. However, no matter how much I struggle to get the function to work, I cannot. If you could clarify the description at the link for me (maybe even provide an example or two) that would great. Thanks for any help!

Here is the link to the description: http://oeis.org/A039739

And here is the link to the sequence: http://oeis.org/A039739/list

-
 I don't get it either, since I can't see how $p(n)$ is defined, and $p(n)$ is used in the description of the sequence. – coffeemath Nov 4 '12 at 2:07 Maybe $p(n)$ is the $n$th prime? – ronno Nov 4 '12 at 2:10 @ronno nope, it appears not – B.D Nov 4 '12 at 2:12 $n$th odd prime, it appears. – Gerry Myerson Nov 4 '12 at 2:51

## 1 Answer

"$a(n)=2q-p(n)$, where $q$ is the prime $\lt p(n)$ for which $p(n) \bmod q$ is maximal."

I think $p(n)$ is the $n$th (odd) prime. So to find, say, $a(5)$, you look at $p(5)$, the 5th odd prime, which is $13$, then you calculate $13\bmod q$ for $q=3,5,7,11$, getting $1,3,6,2$, of which the largest is the $6$ you get from $q=7$. So, $a(5)=2\times7-13=1$.

-
 I have not tried that, but in the sequence provided at the website, the answer to a(5) is not 1 but 3. – Joshua Nov 4 '12 at 2:25 One thing that might be useful to keep in mind--I know that one is not considered a Prime number any more, but it appears that at the time of the post that is was. So instead of 11 being the 5th prime, 7 would be. I checked the equation on other numbers and it still doesn't work, but it did in your example. – Joshua Nov 4 '12 at 2:41 The sequence at oeis starts 1, 1, 3, 3, 1, 5, 3, 3, 5, 3, 1, so $a(5)$ is the 5th term in that sequence, which is 1, not 3. The link does not count 1 as a prime, nor 2 --- just odd primes, as I wrote. – Gerry Myerson Nov 4 '12 at 2:51 Alright, but in the second link I provided, there is a list with the value of n used and the following value, a(n). In this list, if n = 5, then a(n) = 3 instead of 1. – Joshua Nov 4 '12 at 3:03 Ok. I see what you mean. 1 is the 5th number in the sequence, so a(5) should be 1. Why does the list say otherwise? – Joshua Nov 4 '12 at 3:09
show 1 more comment