Roojay 11月 21, 2017
• 在其它设备中阅读本文章

1. The length of Bob’s lap (larger than 0).
2. The length of Charles’ lap (larger than 0).
3. The first number is the number of laps that Bob has to run.
4. The second number is the number of laps that Charles has to run.

Examples:

nbrOfLaps(5, 3); // returns [3, 5]
nbrOfLaps(4, 6); // returns [3, 2]

a 可以表示成 a = kb + r，则 r = a mod b.

d|b , d |r ，但是 a = kb +r

const gcd = function (a, b) {
if (b === 0) return a;
return gcd(b, a % b);
};
const nbrOfLaps = (x, y) => [y, x].map(item => item / gcd(x, y));

The MIT License (MIT)
Copyright (c) 2019, Roojay.