Skip to content

Add FriendlyNumber Implementation#7474

Merged
DenizAltunkapan merged 2 commits into
TheAlgorithms:masterfrom
Rosander0:add-friendly-number
Jun 22, 2026
Merged

Add FriendlyNumber Implementation#7474
DenizAltunkapan merged 2 commits into
TheAlgorithms:masterfrom
Rosander0:add-friendly-number

Conversation

@Rosander0

Copy link
Copy Markdown
Contributor
  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized it.
  • All filenames are in PascalCase.
  • All functions and variable names follow Java naming conventions.
  • All new algorithms have a URL in their comments that points to Wikipedia or other similar explanations.
  • All new algorithms include a corresponding test class that validates their functionality.
  • All new code is formatted with clang-format -i --style=file path/to/your/file.java

@codecov-commenter

codecov-commenter commented Jun 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.88%. Comparing base (631eae3) to head (c7dbdce).

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #7474      +/-   ##
============================================
+ Coverage     79.86%   79.88%   +0.01%     
- Complexity     7333     7340       +7     
============================================
  Files           808      809       +1     
  Lines         23833    23847      +14     
  Branches       4690     4694       +4     
============================================
+ Hits          19035    19050      +15     
+ Misses         4036     4035       -1     
  Partials        762      762              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new number-theory utility for detecting friendly numbers (numbers with the same abundancy index) along with a JUnit test suite to validate core behavior.

Changes:

  • Introduces FriendlyNumber with areFriendly(a, b) based on divisor-sum (sigma) computation.
  • Adds FriendlyNumberTest covering friendly, non-friendly, and invalid input cases.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/main/java/com/thealgorithms/maths/FriendlyNumber.java Implements friendly-number check via sum-of-divisors and cross-multiplication comparison.
src/test/java/com/thealgorithms/maths/FriendlyNumberTest.java Adds unit tests for expected friendly/non-friendly pairs and invalid inputs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/main/java/com/thealgorithms/maths/FriendlyNumber.java Outdated
Comment thread src/main/java/com/thealgorithms/maths/FriendlyNumber.java Outdated
Comment thread src/main/java/com/thealgorithms/maths/FriendlyNumber.java Outdated
@Rosander0 Rosander0 force-pushed the add-friendly-number branch from dd2d403 to 3ac12ba Compare June 18, 2026 12:38
@DenizAltunkapan DenizAltunkapan enabled auto-merge (squash) June 22, 2026 07:21
@DenizAltunkapan DenizAltunkapan merged commit a508fd2 into TheAlgorithms:master Jun 22, 2026
7 checks passed
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.

4 participants