Take the 2-minute tour ×
MathOverflow is a question and answer site for professional mathematicians. It's 100% free, no registration required.

My hope is that this question is "trivial," but it is outside my knowledge base, so I'd appreciate some advice.

Given positive integers $m$ and $n$, find the least prime $p$ such that $p-1 = mnk$ for some $k \geq 1$.

For what I am trying to do, I need an explicit algorithm to find $p$, as opposed to an approximation. Is there a best one known? What is the upper bound on how much larger $p$ might be than $mn$? I am happy to assume that $m$ and $n$ are "sufficiently large" for the algorithm to have nice properties, if that helps.

Thank you. Hopefully the answer is obvious to everyone but me. :-)

share|improve this question
1  
When you write "for $k\ge1$", do you mean "for some $k\ge1$" or "for every $k\ge1$" ?:-( –  Chandan Singh Dalawat Oct 4 '11 at 3:11
    
@Chandan Singh Dalawat: I mean some $k$, in fact the smallest possible $k$. Now edited. –  Aaron Sterling Oct 4 '11 at 15:24

1 Answer 1

Firstly, I don't understand the point of having both $m$ and $n.$ Since only their product appears, call it $k.$ You are then trying to find the smallest prime congruent to $1$ modulo $k.$ The bound for such is a highly nontrivial matter, see (eg)

http://en.wikipedia.org/wiki/Linnik%27s_theorem

EDIT It is believed that you don't have to examine more than $\log^2 k$ multiples to find the first prime in a progression of your type.

share|improve this answer
2  
The question asks for an algorithm. The algorithm will be to test all numbers of the form $mns+1$, for $s=1,2,\ldots$ for primality, using e.g., AKS (or something faster and probabilistic like Miller-Rabin). I don't think there is anything else you can do, as there are no simple ways of generating primes. The running time of this algorithm depends on the smallest prime that you meet and for that see Igor's answer. –  Felipe Voloch Oct 3 '11 at 17:56
    
@Felipe: Yes, thank you. I meant (implicitly) that you should test all the numbers until the bound, but it is much better to be explicit. (although the OP does also ask for the bound explicitly) I suppose that theoretically there could be a better algorithm then testing all the multiples, but I am pretty sure no one knows what it is. –  Igor Rivin Oct 3 '11 at 18:08
    
Thanks, both of you, this is a big help. –  Aaron Sterling Oct 3 '11 at 18:14
    
It might help to do some pre-sieving first, Eratostenes-like. Eg, if mn is odd there is no point in testing the odd multiples of mn; and make similar considerations for all other 'small' primes. –  quid Oct 3 '11 at 18:22
1  
@quid: the $\log q^2$ is apparently a heuristic estimate due to Wagstaff. And you do have a good point about sieving: sieving wants to find many primes, here you are looking for one, so it might or might not help, depending on various subtleties... –  Igor Rivin Oct 3 '11 at 18:57

Your Answer

 
discard

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.