Java icon indicating copy to clipboard operation
Java copied to clipboard

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

Open HetuKariya opened this issue 1 year ago • 2 comments

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.

HetuKariya avatar Sep 23 '25 07:09 HetuKariya

would like to work on this issue

Naimish08 avatar Sep 26 '25 19:09 Naimish08

please merge this pr ans also add hacktoberfest tag

HetuKariya avatar Sep 27 '25 03:09 HetuKariya