function getgcd(a, b) low, high = 0, 0 if(a < b) then low, high = a, b else low, high = b, a end while(high % low ~= 0) do low, high = high % low, low end return low end a, b = io.read("*n", "*n") if(a + b == 101) then a, b = a * 2 - 1, b * 2 - 1 gcd = getgcd(a, b) print((a + b) / gcd) else ret = 200 min2, max2 = a * 2 - 1, a * 2 + 1 for den = 1, 100 do for num = 0, den do -- min <= num / den < max if(min2 * den <= num * 200 and num * 200 < max2 * den) then gcd = getgcd(den, num) ret = math.min(ret, den / gcd) elseif(max2 * den <= num * 2) then break end end end print(ret) end