Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

fix: reject negative input in SumOfSquares - #7539

#7539
Draft
oozan wants to merge 3 commits into
TheAlgorithms:masterTheAlgorithms/Java:masterfrom
oozan:fix-sum-of-squares-negative-input-1784733818oozan/Java:fix-sum-of-squares-negative-input-1784733818Copy head branch name to clipboard
Draft

fix: reject negative input in SumOfSquares#7539
oozan wants to merge 3 commits into
TheAlgorithms:masterTheAlgorithms/Java:masterfrom
oozan:fix-sum-of-squares-negative-input-1784733818oozan/Java:fix-sum-of-squares-negative-input-1784733818Copy head branch name to clipboard

Conversation

@oozan

@oozan oozan commented Jul 22, 2026

Copy link
Copy Markdown

Description

Rejects negative inputs in SumOfSquares instead of returning the mathematically incorrect result 3.

The public method now throws IllegalArgumentException with a clear message, and its Javadoc documents the behavior.

Testing

  • Added a regression test for negative input
  • Compiled the implementation directly with javac
  • Verified the existing one-, two-, three-, and four-square cases
  • Verified that negative input throws IllegalArgumentException

Closes #7538

Checklist

  • Filenames use PascalCase
  • Java naming conventions are followed
  • The existing algorithm documentation link is preserved
  • The behavior is covered by a corresponding test
  • The change follows the existing formatting style

AI assistance was used to prepare this focused fix. I reviewed and validated the implementation.

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.

[BUG] SumOfSquares accepts negative input

1 participant

Morty Proxy This is a proxified and sanitized view of the page, visit original site.