algorithm - Minimum count of numbers to be inserted in [a,b] such that GCD of 2 consecutive numbers is 1 -


this question asked in topcoder - srm 577. given 1 <= < b <= 1000000, minimum count of numbers inserted between a & b such no 2 consecutive numbers share positive divisor greater 1.

example:

  1. a = 2184; b = 2200. need insert 2 numbers 2195 & 2199 such condition holds true. (2184,2195,2199,2200)
  2. a = 7; b= 42. 1 number sufficient insert between them. number can 11.
  3. a = 17;b = 42. gcd 1, no need insert number.

now, interesting part given range [1,1000000] never require more 2 elements inserted between a , b. more, 2 numbers speculated a+1 , b-1 though yet proven.

  1. can prove this?
  2. can extended larger range of numbers also? say, [1,10^18] etc

doh, sorry. counterexample have is

a=3199611856032532876288673657174760 b=3199611856032532876288673657174860 

(would nice if stupid site allowed edit posts)


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -