Skip to content

Refactor ChineseRemainderTheorem: reuse PrimeFactorization, add tests#1314

Merged
williamfiset merged 5 commits intomasterfrom
refactor-chinese-remainder-theorem
Apr 2, 2026
Merged

Refactor ChineseRemainderTheorem: reuse PrimeFactorization, add tests#1314
williamfiset merged 5 commits intomasterfrom
refactor-chinese-remainder-theorem

Conversation

@williamfiset
Copy link
Copy Markdown
Owner

Summary

  • Remove 4 duplicated private methods (primeFactorization, pollardRho, isPrime, gcf) and delegate to the shared PrimeFactorization class
  • Simplify ListIterator-based prime-power grouping with a cleaner index-based loop
  • Clean up Javadoc with proper @link references and Unicode math notation
  • Add 17 JUnit 5 tests covering eliminateCoefficient, crt, reduce, egcd, and full reduce+crt integration

Test plan

  • bazel test //src/test/java/com/williamfiset/algorithms/math:ChineseRemainderTheoremTest — all 17 tests pass

🤖 Generated with Claude Code

williamfiset and others added 5 commits April 2, 2026 15:39
Remove duplicated primeFactorization, pollardRho, isPrime, and gcf methods
in favor of the shared PrimeFactorization class. Simplify prime-power grouping
loop and clean up Javadoc. Add 17 JUnit 5 tests covering eliminateCoefficient,
crt, reduce, egcd, and full reduce+crt integration.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Restore primeFactorization, pollardRho, isPrime, and supporting methods
as private methods within ChineseRemainderTheorem rather than delegating
to PrimeFactorization. Uses the improved Miller-Rabin primality test and
overflow-safe mulMod instead of the original trial-division isPrime.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@williamfiset williamfiset merged commit 0e0dc06 into master Apr 2, 2026
2 checks passed
@williamfiset williamfiset deleted the refactor-chinese-remainder-theorem branch April 2, 2026 22:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant