文档服务地址:http://47.92.0.57:3000/ 周报索引地址:http://47.92.0.57:3000/s/NruNXRYmV

Commit 54c46443 by majexh

init

parents
# 对最近的笔试题的总结
> sponsor by @王腾 感谢王腾学长的支持
## 百度
[ds](./百度/)
\ No newline at end of file
// 运行 node ./first.js n
// 运行 node ./first.js n
/**
* 整个题就是求 最小公倍数 和 最大公约数 的差 的最大值 其中取得两个数 都在 [2,n]中
* 第一个想法就是求最大公约数 然后 a*b / 最大公约数 得到 最小公倍数 不过 n 最大到 10^9 不用试都知道超时了
* 第二个想法 是当时学长自己做的 直接用 n * (n - 1) - 1
* 就是 n 和 n - 1 在n >= 3的时候是互质的 他们的最小公倍数 就是 n * n - 1 最大公约数就是1
* @param {number} n 输入的数字
*/
function getResult(n) {
return n * (n - 1) - 1
}
console.log(getResult(process.argv[2]))
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment