4

This question was asked in TopCoder - SRM 577. Given 1 <= a < b <= 1000000, what is the minimum count of numbers to be inserted between a & b such that no two consecutive numbers will share a positive divisor greater than 1.

Example:

  1. a = 2184; b = 2200. We need to insert 2 numbers 2195 & 2199 such that the condition holds true. (2184,2195,2199,2200)
  2. a = 7; b= 42. One number is sufficient to insert between them. The number can be 11.
  3. a = 17;b = 42. The GCD is already 1, so no need to insert any number.

Now, the interesting part is that for the given range [1,1000000] we never require more than 2 elements to be inserted between a and b. Even more, the 2 numbers are speculated to be a+1 and b-1 though it yet to be proven.

  1. Can anyone prove this?
  2. Can it be extended to larger range of numbers also? Say, [1,10^18] etc
baskar_p
  • 665
  • 5
  • 16
  • Seems related to the [twin prime conjecture](http://en.wikipedia.org/wiki/Twin_prime). My gut feeling is that you might satisfy certain bounds for this range, but you won't be able to generalize the results. – Brett Hale May 04 '13 at 13:44

4 Answers4

2

Doh, sorry. The counterexample I have is

a=3199611856032532876288673657174760
b=3199611856032532876288673657174860

(Would be nice if this stupid site allowed everyone to edit its posts)

meh
  • 21
  • 2
1

Each number has some factorization. If a, b each have a little number of distinct prime factors (DPF), and distance between them is large, it is certain there will be at least one number between them, whose set of DPF s has no elements in common with the two. So this will be our one-number pick n, such that gcd(a,n) == 1 and gcd(n,b) == 1. The higher we go, the more prime factors there are, potentially, and the probability for even gcd(a,b)==1 is higher and higher, and also for the one-num-in-between solution.

When will one-num solution not be possible? When a and b are highly-composite - have a lot of DPF s each - and are situated not too far from each other, so each intermediate number has some prime factors in common with one or two of them. But gcd(n,n+1)==1 for any n, always; so picking one of a+1 or b-1 - specifically the one with smallest amount of DPF s - will decrease the size of combined DPF set, and so picking one number between them will be possible. (... this is far from being rigorous though).


This is not a full answer, more like an illustration. Let's try this.

-- find a number between the two, that fulfills the condition
gg a b = let fs=union (fc a) (fc b) 
         in filter (\n-> null $ intersect fs $ fc n) [a..b]

fc = factorize

Try it:

Main> gg 5 43
[6,7,8,9,11,12,13,14,16,17,18,19,21,22,23,24,26,27,28,29,31,32,33,34,36,37,38,39
,41,42]

Main> gg 2184 2300
[2189,2201,2203,2207,2209,2213,2221,2227,2237,2239,2243,2251,2257,2263,2267,2269
,2273,2279,2281,2287,2291,2293,2297,2299]

Plenty of possibilities for just one number to pick between 5 and 43, or between 2184 and 2300. But what about the given pair, 2184 and 2200?

Main> gg 2184 2200
[]

No one number exists to put in between them. But obviously, gcd (n,n+1) === 1:

Main> gg 2185 2200
[2187,2191,2193,2197,2199]
Main> gg 2184 2199
[2185,2189,2195]

So having picked one adjacent number, we indeed have plenty of possibilities for the 2nd number. Your question is, to prove that it is always the case.

Let's look at their factorizations:

Main> mapM_ (print.(id&&&factorize)) [2184..2200]
(2184,[2,2,2,3,7,13])
(2185,[5,19,23])
(2186,[2,1093])
(2187,[3,3,3,3,3,3,3])
(2188,[2,2,547])
(2189,[11,199])
(2190,[2,3,5,73])
(2191,[7,313])
(2192,[2,2,2,2,137])
(2193,[3,17,43])
(2194,[2,1097])
(2195,[5,439])
(2196,[2,2,3,3,61])
(2197,[13,13,13])
(2198,[2,7,157])
(2199,[3,733])
(2200,[2,2,2,5,5,11])

It is obvious that the higher the range, the easier it is to satisfy the condition, because the variety of contributing prime factors is greater.

(a+1) won't always work by itself - consider 2185, 2200 case (similarly, for 2184,2199 the (b-1) won't work).

So if we happen to get two highly composite numbers as our a and b, picking an adjacent number to either one will help, because usually it will have only few factors.

Will Ness
  • 70,110
  • 9
  • 98
  • 181
  • for [2185,2200] we could add 2187 which solves the problem. We only need to insert 2 numbers if we happen to fail the following 2 conditions: 1. if `gcd(a,b) == 1` 2. if there exists c in interval (a,b) such that `gcd(a,c) == 1` & `gcd(c,b)==1` – baskar_p May 03 '13 at 07:46
  • what I meant was, for [2185,2200], 2186 won't do by itself (because it's even, as 2200 is even). 2185 is not as highly composite number as 2184, so naturally it's easier to find a solution with it. between two not highly composite numbers, we're almost certain to find just one number that satisfies the condition. And as you say in the comments, if the two are coprime we don't need to add any number between them. – Will Ness May 03 '13 at 08:16
  • I'm not sure what exactly you wanted to tell. How about more than 2 elements between the range [a,b]? – baskar_p May 03 '13 at 11:47
  • @baskar_p OK, I've added some wording there. :) – Will Ness May 03 '13 at 14:01
0

This answer addresses that part of the question which asks for a proof that a subset of {a,a+1,b-1,b} will always work. The question says: “Even more, the 2 numbers are speculated to be a+1 and b-1 though it yet to be proven. Can anyone prove this?”. This answer shows that no such proof can exist.

An example that disproves that a subset of {a,a+1,b-1,b} always works is {105, 106, 370, 371} = {3·5·7, 2·53, 2·5·37, 7·53}. Let (x,y) denote gcd(x,y). For this example, (a,b)=7, (a,b-1)=5, (a+1,b-1)=2, (a+1,b)=53, so all of the sets {a,b}; {a, a+1, b}; {a,b-1,b}; and {a, a+1, b-1,b} fail.

This example is a result of the following reasoning: We want to find a,b such that every subset of {a,a+1,b-1,b} fails. Specifically, we need the following four gcd's to be greater than 1: (a,b), (a,b-1), (a+1,b-1), (a+1,b). We can do so by finding some e,f that divide even number a+1 and then construct b such that odd b is divisible by f and by some factor of a, while even b-1 is divisible by e. In this case, e=2 and f=53 (as a consequence of arbitrarily taking a=3·5·7 so that a has several small odd-prime factors).

James Waldby - jwpat7
  • 8,593
  • 2
  • 22
  • 37
  • 1
    You could insert one number (107) between [105,371] such that gcd(105,107) = 1 & gcd(107,371) = 1. You don't need to insert two numbers between them. – baskar_p May 03 '13 at 07:41
  • Certainly, @baskar_p, but the question asks for a proof that a subset of {a,a+1,b-1,b} will always work. See edit. – James Waldby - jwpat7 May 03 '13 at 07:51
  • 1
    We need to insert 2 numbers only when we are unable to insert 0 or 1 number between the interval. If you happen to read the question clearly, I had mentioned "we never require more than 2 elements". – baskar_p May 03 '13 at 07:58
0
a=3199611856032532876288673657174860
b=3199611856032532876288673657174960

appears to be a counterexample.

meh
  • 1