Repository navigation
#47: Add lcm(a, b) to the math module - #48
Merged
Merged
Conversation
Checklist items 1 and 2. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
|
Pendulum: cb0f274 goes to the review while its required checks run; the review stage waits for them beside its reviewer. |
Contributor
Author
|
Pendulum: validation green on cb0f274; ready for the reviewer. |
Contributor
Author
There was a problem hiding this comment.
Pendulum reviewer: one comment-only pass, 1 comment(s).
Acceptance as the reviewer judged it:
- 1: met (
lcmis exported at line 128: it throwsRangeErrorwhen either argument failsNumber.isInteger, returns0when either is0, and otherwise returnsMath.abs((a / gcd(a, b)) * b), which is non-negative and sign-insensitive. The diff only appends tosrc/math.mjs, so the existing ex… - 2: met (Line 3 imports
lcmfrom../src/math.mjs, and thelcmtest at lines 140-148 asserts exact values forlcm(4, 6) === 12,lcm(-4, 6) === 12,lcm(0, 5) === 0,lcm(7, 1) === 7and thatlcm(2.5, 4)throwsRangeError, all against the real function.) - 3: met (I ran
npm teston the PR head: 19 tests, 19 pass, 0 fail. The diff removes or loosens no existing assertion; the only changed existing line is the import, which addslcm.) - 4: met (Line 126 adds one
It also exportslcm(a, b)...paragraph in the same form as thefactorialandgcdentries, states theRangeErrorcase for non-integers, and is followed by a usage example (lcm(4, 6); // 12) at lines 128-131.)
Contributor
Author
|
Pendulum: cb0f274 is reviewed and validated; it merges once its required checks are green. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
✅ Merged in 3 min 50 s · $0.52
Issue #47 → PR #48 · merged through your merge queue at 3:37 PM PST · billed to your API key
Acceptance
src/math.mjsexportslcm(a, b): non-negative least common multiple, sign-insensitive,0when either argument is0,RangeErrorfor non-integers; existing exports unchangedsrc/math.mjs(newlcmappended; no existing function touched)test/math.test.mjs, testlcmtest/importslcmfrom../src/math.mjsand checkslcm(4, 6) === 12,lcm(-4, 6) === 12,lcm(0, 5) === 0,lcm(7, 1) === 7, and thatlcm(2.5, 4)throwsRangeErrortest/math.test.mjs(import extended; newlcmtest also coverslcm(4, -6),lcm(5, 0),lcm(4, 2.5))test/math.test.mjs, testlcmnpm testpasses, existing tests includednpm test: 19 tests, 19 passREADME.mddocumentslcm(a, b)in the same style, with a usage example and theRangeErrorcaseREADME.md(new entry aftergcd)factorial/gcdentriesValidation
npm test: pass (19 tests, 0 failures).Fake-only proofs
none
Assumptions
lcmis computed as|a / gcd(a, b) * b|using the existinggcdexport; dividing first keeps intermediate values small.lcm(0, 0)returns0(the issue says0when either argument is0), and the result is never-0.!Number.isInteger(x), soNaN,Infinityand non-number values also throwRangeError, matchingfactorial's check.test/math.test.mjs, which already imports from../src/math.mjs, rather than a new file.Undone
Nothing.
🤖 Generated with Claude Code
Closes #47