Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:

And here is the link to the sequence:

share|cite|improve this question
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 – Benjamin Dickman Nov 4 '12 at 2:12
$n$th odd prime, it appears. – Gerry Myerson Nov 4 '12 at 2:51

"$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$.

share|cite|improve this answer
I have not tried that, but in the sequence provided at the website, the answer to a(5) is not 1 but 3. – CgRobot 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. – CgRobot 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. – CgRobot 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? – CgRobot Nov 4 '12 at 3:09

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.