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:
a = 2184
;b = 2200
. need insert 2 numbers2195
&2199
such condition holds true. (2184,2195,2199,2200)a = 7
;b= 42
. 1 number sufficient insert between them. number can 11.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.
- can prove this?
- 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
Post a Comment