Skip to content

[FEATURE REQUEST] Would like to add Bitwise GCD (Stein's algorithm) in the Bit Manipulation Section. #6542

@HetuKariya

Description

@HetuKariya

What would you like to Propose?

Provides gcd for int and long, returns non-negative gcd(0,x)=|x|. Compute gcd(|a|, |b|) using Stein's algorithm (binary GCD). Handles negative inputs and Integer.MIN_VALUE safely.

Issue details

BitwiseGCD.java implements the binary GCD (Stein’s) algorithm for int and long and includes a main with ad-hoc tests. Create a well-formed issue describing missing items: formal unit tests, CI integration, documentation, edge-case verification, microbenchmarks, and suggested improvements (API/behavior consistency, extended GCD, performance regression tests). This issue tracks adding those items and provides reproducible steps, expected results, failing/ambiguous behaviors to check, and recommended fixes.

Additional Information

Algorithm: Binary GCD (Stein’s algorithm).Repeatedly remove common factors of 2, make both operands odd by shifting, subtract the smaller from the larger, repeat until one becomes 0, then restore powers of two.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions