FunctionRacerProblemsRace

Can the Pair Be Reached

HardMathPython, JavaScript, TypeScript, Java, C++

You hold a pair of numbers (a, b). One move replaces (x, y) with (x + y, y) or with (x, x + y). Return True if some number of moves (possibly none) turns (a, b) into (c, d).

Example 1

a 1
b 1
c 3
d 5
returns true

(1, 1) to (1, 2) to (3, 2) to (3, 5).

Example 2

a 1
b 1
c 2
d 2
returns false

After the first move the two numbers are never equal again.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Math problems