Relative Prime Gaps: Fast Algorithm for Calc.

In summary, the largest gap between consecutive numbers that are relatively prime to all of them is 14.
  • #1
ppnl
37
0
Given the first N prime numbers what is the largest gap between consecutive numbers that are relatively prime to all of them? Anyone know of a fast algorithm for calculating this?
 
Physics news on Phys.org
  • #3
coolul007 said:

Yes I know that there are arbitrarily large prime gaps. I'm asking something different.

Again, given the first N primes, say 2,3,5,7 and 11, what is the largest gap between consecutive numbers not divisible by any of these? the answer for this (where N=5) is 14. I want a fast way to calculate this for any value of N.
 
  • #4
ppnl said:
Yes I know that there are arbitrarily large prime gaps. I'm asking something different.

Again, given the first N primes, say 2,3,5,7 and 11, what is the largest gap between consecutive numbers not divisible by any of these? the answer for this (where N=5) is 14. I want a fast way to calculate this for any value of N.


It must be the global warming but I don't get it: for any integer [itex]\,k\,[/itex] , any [itex]\,k\,[/itex] consecutive integers will have exactly one

multiple of k (in fact, exactly one integer [itex]\,=i\pmod j\,\,\,,\,\,\forall i=0,1,2,...,k-1\,[/itex] ), thus: any list of two (2) consecutive integers will

have exactly one element divisible by 2 , from where I can't understand how you came up with 14, and I gather then that you must be trying

to convey to us something different from what I am understanding...

DinAntonio
 
  • #5
Ok, let me try again.

What is the biggest gap between consecutive numbers not divisible by two? Obviously it is two. 3 and 5 for example are consecutive numbers not divisible by two. They are not consecutive integers but they are consecutive numbers not divisible by two. They are also consecutive primes despite not being consecutive integers. Two is the answer for N=1.

Now take the primes 2 and 3. What is the largest gap that can exist between consecutive numbers indivisible by 2 or 3? I don't mean consecutive integers here. I mean consecutive coprimes to 2 and 3. For example 7 and 11 are consecutive coprimes to 2 and 3. The answer for N=2 is 4.

And what is the maximum gap between consecutive numbers that are coprime to 2, 3 and 5? The answer is 6. For example 23 and 29 are consecutive coprimes to 2, 3 and 5 with a gap of 6 between them. The answer for N=3 is 6.


In the more general case given a random set of prime numbers what is the maximum gap between consecutive coprimes to that set of prime numbers?
 
  • #6
ppnl said:
Ok, let me try again.

What is the biggest gap between consecutive numbers not divisible by two? Obviously it is two. 3 and 5 for example are consecutive numbers not divisible by two They are not consecutive integers but they are consecutive numbers not divisible by two. They are also consecutive primes despite not being consecutive integers. Two is the answer for N=1
Now take the primes 2 and 3. What is the largest gap that can exist between consecutive numbers indivisible by 2 or 3? I don't mean consecutive integers here. I mean consecutive coprimes to 2 and 3. For example 7 and 11 are consecutive coprimes to 2 and 3. The answer for N=2 is 4.

And what is the maximum gap between consecutive numbers that are coprime to 2, 3 and 5? The answer is 6. For example 23 and 29 are consecutive coprimes to 2, 3 and 5 with a gap of 6 between them. The answer for N=3 is 6. .

Ooooooooh! I think I finally get what you meant! You actually wanted to ask: given the first n primes [itex]\,p_1,...,p_n\,[/itex] , what is the maximal possible difference of the form

[itex]\,a-b\,[/itex] , [itex]\,a>b\,\,,\,\,and\,\,\,\forall\,k\,\,,\,a<k<b\,\,\,\,\,p_j\mid k\,\,\,,\,\,\text{for some}\,\,1\leq j\leq n\,\,?[/itex]


In the more general case given a random set of prime numbers what is the maximum gap between consecutive coprimes to that set of prime numbers?

Ok, now I understood but I've no idea about your question. In case of first consecutive primes the answer is always an even

number, obviously, and perhaps easier to calculate than taking a random set of primes, which seems to make this a hopeless question...but who knows?

DonAntonio
 
  • #7
DonAntonio said:
Ooooooooh! I think I finally get what you meant! You actually wanted to ask: given the first n primes [itex]\,p_1,...,p_n\,[/itex] , what is the maximal possible difference of the form

[itex]\,a-b\,[/itex] , [itex]\,a>b\,\,,\,\,and\,\,\,\forall\,k\,\,,\,a<k<b\,\,\,\,\,p_j\mid k\,\,\,,\,\,\text{for some}\,\,1\leq j\leq n\,\,?[/itex]

Yes I think that's it but it really obscures what is going on. Just do a sieve of Eratosthenes using only the first N primes and find the largest relative prime gap that it leaves. But this method of finding the gaps is very slow.

There is another method using permutations of the prime list but it is a mess for me to program.

I know there has been a lot of work on prime gaps. I was just wondering if anyone had considered relative prime gaps.
 
  • #8
Let Xn be the product of the first n primes. Let Pn+1 be the n+1th prime. Let k be any positive integer. Then kXn+2 to kXn+(Pn+1)-1 are all multiples of at least one of the first n primes. Also kXn-2 to kXn-(Pn+1)+1 is also a prime gap of the same size. I would conjecture they are the largest prime gap.

Note that your prime gap function is symetric around Xn(k+1/2). And periodic with period Xn.
 
  • #9
robert2734 said:
Let Xn be the product of the first n primes. Let Pn+1 be the n+1th prime. Let k be any positive integer. Then kXn+2 to kXn+(Pn+1)-1 are all multiples of at least one of the first n primes. Also kXn-2 to kXn-(Pn+1)+1 is also a prime gap of the same size. I would conjecture they are the largest prime gap.

Note that your prime gap function is symetric around Xn(k+1/2). And periodic with period Xn.
Actually, there can be a larger gap than that! For example, the first 5 primes are 2,3,5,7,11 and the prime gap can be as large as 14. Let a be the prior prime and a + 14 be the next prime. The 13 number gap between these two primes can be filled with numbers divisible respectively by 6,5,2,3,2,7,30,11,2,3,2,5,42. As can be seen each is a product of one or more of the first 5 primes. 14 is a larger number than the 6th prime.
 
Last edited:
  • #10
ramsey2879 said:
Actually, there can be a larger gap than that! For example, the first 5 primes are 2,3,5,7,11 and the prime gap can be as large as 14. Let a be the prior prime and a + 14 be the next prime. The 13 number gap between these two primes can be filled with numbers divisible respectively by 6,5,2,3,2,7,30,11,2,3,2,5,42. As can be seen each is a product of one or more of the first 5 primes. 14 is a larger number than the 6th prime.

Now we are getting somewhere.

It is easy to show that the max gap for the first N prime numbers is at least two times the N-1th prime. We can always construct a gap of exactly this size. We construct the gap by listing the smallest prime a position in the gap is divisible by like this:



N=3 P,2,3,2,5,2,P
N=4 P,2,5,2,3,2,5,2,7,2,3,2,5,2,P
N=5 P,2,3,2,7,2,5,2,3,2,7,2,11,2,3,2,5,2,7,2,3,2,P

See the pattern? If so you can easily see that this gap always exists, is equal to two times the N-1th prime and there are exactly two of them. But is this always the largest gap? That would be a beautiful result if you could prove it. It is true for n=1,2,3,4,5,6,7 and 8.

But it fails for N=9. I would like to know if it fails for an infinite number of cases, how often it fails and some idea of the conditions that cause it to fail. So far it seems the failures are rare but I'm limited on how far I can compute the gaps.
 
  • #11
N=4 P,2,5,2,3,2,5,2,7,2,3,2,5,2,P


Your middle 5 is four away from the first 5 and six away from the last 5. That doesn't happen.
Following my algorithm for N=4, 2*3*5*7=210 and 212 to 220 is a prime gap. 200 to 208 is also a prime gap. 221 is actually 13*17 and 209 is 11*19 but neither is a multiple of 2,3,5 or 7.

N=4 P,2,3,2,5,2,7,2,3,2,P. You can't do better.

In your example for N=5, the 7's are shifted.
 
  • #12
robert2734 said:
Your middle 5 is four away from the first 5 and six away from the last 5. That doesn't happen.
Following my algorithm for N=4, 2*3*5*7=210 and 212 to 220 is a prime gap. 200 to 208 is also a prime gap. 221 is actually 13*17 and 209 is 11*19 but neither is a multiple of 2,3,5 or 7.

N=4 P,2,3,2,5,2,7,2,3,2,P. You can't do better.

In your example for N=5, the 7's are shifted.

OOPS! Sorry, my bad. That should be:

N=3--- P,2,3,2,5,2,P=2*3
N=4--- P,2,3,2,5,2,7,2,3,2,P=2*5
N=5--- P,2,5,2,3,2,7,2,11,2,3,2,5,2,P=2*7

To construct this gap we place the two largest primes in the middle with a two between:

...17,2,19...

Now going to the right we number the positions starting with 2:

...17,2,19,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16

Then we reduce these numbers to the smallest prime that divides them:

...17,2,19,2,3,2,5,2,7,2,3,2,11,2,13,2,3,2,P

Then we reflect to the left side:

P,2,3,2,13,2,11,2,3,2,7,2,5,2,3,2,17,2,19,2,3,2,5,2,7,2,3,2,11,2,13,2,3,2,P

Clearly a gap with this pattern always exists, you can get two of them by swapping the center big primes and for small N at least it is often the largest gap.
 
  • #13
Yes. Your construction is better than mine. For N=5, 120=2x3x5, 119=7x, and 121=11x. So from 114 to 126 it is 2,5,2,3,2,7,2,11,2,3,2,5,2. A gap of 13. I only got a gap of 11 from 2312 to 2322 2,3,2,5,2,7,2,3,2,11,2.

For N=6 we have 210=2x3x5x7. 209=11x. But 211 isn't a multiple of 13. So we add 2310 to 211 and try again. Eventually we find 4*2310+211 is a multiple of 13. So we have from 9440 to 9460 2,3,2,7,2,5,2,3,2,11,2,13,2,3,2,5,2,7,2,3,2 a gap of 21.
 
  • #14
And for N=7 we get a gap of 2*13=26 as expected and with N=8 we get 2*17=34 as expected.

But for N=9 we expect a maximum gap of 2*19=38. A gap of that size does exist but we have a larger gap with of 40 with an irregular structure:

P,2,3,2,5,2,11,2,3,2,13,2,23,2,3,2,7,2,19,2,3,2,17,2,5,2,3,2,11,2,7,2,3,2,5,2,13,2,3,2,P

At N=10 and 11 we again have the expected 2*23=46 and 2*29=58 as maximum gaps. But at N=12 we again have a larger than expected maximum gap of 66 again with an irregular structure.

Calculating past this gets difficult unless I improve my algorithm.
 

1. What is the concept of relative prime gaps?

Relative prime gaps refer to the differences between consecutive numbers that have no common factors besides 1. For example, the numbers 3 and 5 have a relative prime gap of 2, while the numbers 8 and 10 have a relative prime gap of 2 as well, even though their absolute difference is 2.

2. Why is there a need for a fast algorithm for calculating relative prime gaps?

The study of relative prime gaps is important in number theory and cryptography. A fast algorithm for calculating these gaps can greatly improve the efficiency of these fields, allowing for more complex calculations and faster analysis of data.

3. How does this algorithm work?

The algorithm uses a combination of sieving and pre-computed values to efficiently determine the relative prime gaps between a given range of numbers. It first sieves out all numbers with small prime factors, then uses pre-computed data to quickly check for larger prime factors. This results in a highly optimized and fast algorithm for calculating relative prime gaps.

4. What are the potential applications of this algorithm?

This algorithm can be used in various fields such as number theory, cryptography, and data analysis. It can help in identifying patterns and trends in data, as well as improving the efficiency of encryption and decryption methods in cryptography.

5. Are there any limitations to this algorithm?

Like any algorithm, there are limitations to the speed and accuracy of this method. It may not be able to efficiently calculate relative prime gaps for extremely large numbers, and there may also be potential for errors in the pre-computed data used. Further research and improvements can help overcome these limitations.

Similar threads

  • Linear and Abstract Algebra
Replies
2
Views
793
  • Linear and Abstract Algebra
Replies
2
Views
773
  • Programming and Computer Science
Replies
14
Views
2K
  • Linear and Abstract Algebra
Replies
1
Views
820
  • Programming and Computer Science
Replies
22
Views
731
  • Linear and Abstract Algebra
Replies
4
Views
1K
Replies
8
Views
357
  • General Math
Replies
24
Views
1K
  • Math Proof Training and Practice
Replies
1
Views
990
  • Precalculus Mathematics Homework Help
Replies
3
Views
934
Back
Top