Skip to content

[BUG] SumOfSquares accepts negative input #7538

Closed

Description

@oozan

Description

SumOfSquares.minSquares currently returns 3 for negative inputs even though negative integers cannot be represented as sums of integer squares.

Expected behavior

The method should reject negative input with IllegalArgumentException.

Reproduction

Calling SumOfSquares.minSquares(-1) currently returns 3 instead of reporting invalid input.

Activity

  1. priyanshuvishwakarma273403 commented on Jul 22, 2026

    @priyanshuvishwakarma273403
    Contributor

    hy can i fix this issue could you please assign this to me ?

  2. Hridya102 commented on Jul 23, 2026

    @Hridya102

    Hii , hope you are doing well. The method appears to have input validation, but minSquares(-1) still returns 3. It looks like the validation is either not being reached or the IllegalArgumentException is being suppressed. The negative-input check should execute before the algorithm, and the exception should be allowed to propagate to the caller instead of returning a default value.

  3. dhruvshukla0407-dotcom commented on Jul 25, 2026

    @dhruvshukla0407-dotcom

    Hey its is my first contri so can i try contributing to this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions