math: uniquePaths and leastCommonMultiple return non-integers below 2^53; iterative Euclid is subtraction-based and can hang
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 停滞
- 技术栈
- javascript
调研方向
The issue points to pascalTriangle, dpUniquePaths, leastCommonMultiple, and euclideanAlgorithmIterative, and compares the iterative Euclidean implementation with the recursive % version in the same folder. Read those implementations and their existing tests, then reproduce the reported inputs. Done means the three functions return the stated correct results and the iterative algorithm handles large inputs promptly; an open pull request is already linked.
由索引模型根据 Issue 内容生成。
描述
Three small issues in the same family. All the true results fit safely in a JS number.
uniquePaths(23, 36)returns3489348548829780.5(a non-integer).uniquePaths(29, 29)returns7648690600760441, butdpUniquePathsgives the correct7648690600760440. Cause:pascalTrianglemultiplies before dividing, so the intermediate product exceeds 2^53. 25 wrong grids up to 40×40.leastCommonMultiple(549533988, 76324165)returns2747669939.9999995; expected2747669940. Cause:Math.abs(a * b) / gcdoverflows before dividing. Fix:Math.abs(a / gcd * b).euclideanAlgorithmIterativeuses repeated subtraction, which takes O(max/min) steps.(1e8, 1)takes about 1 s and(2**53 - 1, 2)effectively never finishes, while the recursive%version in the same folder takes under 1 ms. Fix: use%.
Found during an independent property-based audit of this repo (full report and reproducible harness: https://github.com/devladpopov/algorithm-autopsy/tree/main/autopsy-02).
- 主要语言
- JavaScript
- 星标
- 197k
- 派生
- 31k
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
trekhleb/javascript-algorithms 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
trekhleb/javascript-algorithms#2231 ·
-
难度 2/5 1-3 小时 新手友好度 76/100
trekhleb/javascript-algorithms#2225 ·
-
BinarySearchTreeNode removing可能已有人在做 @bbonch 于 261 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
trekhleb/javascript-algorithms#2102 · 1 条评论 ·
-
Trie.deleteWord fails for words containing characters outside the BMP (e.g. emoji)可能已有人在做 @Shubham-Padkonde 于 4 天前认领。 未关闭
难度 1/5 1 小时以内 新手友好度 35/100
trekhleb/javascript-algorithms#2237 ·
-
bellmanFord: runs in O(V²·E) rather than the O(V·E) / O(E) stated in README可能已有人在做 @Shubham-Padkonde 于 4 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 35/100
trekhleb/javascript-algorithms#2236 ·
查看 trekhleb/javascript-algorithms 的全部 Issue
相似的 Issue
-
enhancement javascript python
难度 2/5 1-3 小时 新手友好度 66/100
jlab-sensing/ENTS-backend#851 ·
维护者通常 2 天内回复
-
难度 1/5 1-3 小时 新手友好度 86/100
guilhermerodz/input-otp#157 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 82/100
davidjerleke/embla-carousel#1414 ·
维护者通常 4 天内回复
-
0. Needs triage bug
难度 2/5 1-3 小时 新手友好度 67/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复