-
-
Save chux0519/d4944398db42a314bdfe874eeab456ff to your computer and use it in GitHub Desktop.
Sheep
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 最大公约数 | |
const gcd = (a, b) => a === 0 ? b : gcd(b % a, a) | |
// 最小公倍数 | |
const lcm = arr => arr.reduce((a, b) => a * b / gcd(a, b), 1) | |
const overallTotal = 9 / 10 | |
const overallAvg = overallTotal / 3 | |
for (let x = 2; ; ++x) { | |
if (1 / x <= overallAvg) break | |
for (let y = x + 1; ; ++y) { | |
if (1 / y <= (overallTotal - 1 / x) / 2) break | |
for (let z = y + 1; ; ++z) { | |
const m = lcm([x, y, z]) | |
const n = m - 1 | |
const total = n / m | |
const avg = total / 3 | |
if (1 / x <= avg) break | |
if (1 / y <= (total - 1 / x) / 2) break | |
// important: z > n | |
if (z > n && (1 / z < (total - 1 / x - 1 / y))) break | |
if (m / x + m / y + m / z + 1 === m) { | |
console.log(x, y, z, n) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment