We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
If the two kangaroos met, then there woulde be an integer n such that x1 + n * v1 = x2 + n * v2. Subtracting x1 from both sides, we get that n * v1 = x2 - x1 + n * v2. Then we subtract n * v2 from both sides and we get n * v1 - n * v2 = x2 - x1. Factoring out n from the left side of the equation, n * (v1 - v2) = (x2 - x1). We can the divide both sides by (v1 - v2) and we get (x2 - x1) / (v1 - v2). If this is an integer, then (x2 - x1) % (v1 - v2) has to equal 0.
Number Line Jumps
You are viewing a single comment's thread. Return to all comments →
If the two kangaroos met, then there woulde be an integer n such that x1 + n * v1 = x2 + n * v2. Subtracting x1 from both sides, we get that n * v1 = x2 - x1 + n * v2. Then we subtract n * v2 from both sides and we get n * v1 - n * v2 = x2 - x1. Factoring out n from the left side of the equation, n * (v1 - v2) = (x2 - x1). We can the divide both sides by (v1 - v2) and we get (x2 - x1) / (v1 - v2). If this is an integer, then (x2 - x1) % (v1 - v2) has to equal 0.