2424 */
2525public final class BitwiseGCD {
2626
27- private BitwiseGCD () { }
27+ private BitwiseGCD () {
28+
29+ }
2830
2931 /**
3032 * Computes GCD of two long values using Stein's algorithm (binary GCD).
@@ -104,11 +106,15 @@ private static long absOrThrowIfOverflow(long x) {
104106 * will be thrown.
105107 */
106108 public static long gcd (long ... values ) {
107- if (values == null || values .length == 0 ) return 0L ;
109+ if (values == null || values .length == 0 ) {
110+ return 0L ;
111+ }
108112 long result = values [0 ];
109113 for (int i = 1 ; i < values .length ; i ++) {
110114 result = gcd (result , values [i ]);
111- if (result == 1L ) return 1L ; // early exit
115+ if (result == 1L ) {
116+ return 1L ; // early exit
117+ }
112118 }
113119 return result ;
114120 }
@@ -117,13 +123,14 @@ public static long gcd(long... values) {
117123 * BigInteger-backed gcd that works for the full integer range (and beyond).
118124 * This is the recommended method when inputs may be Long.MIN_VALUE or when you
119125 * need an exact result even if it is greater than Long.MAX_VALUE.
120- *
121126 * @param a first value (may be negative)
122127 * @param b second value (may be negative)
123128 * @return non-negative gcd as a {@link BigInteger}
124129 */
125130 public static BigInteger gcdBig (BigInteger a , BigInteger b ) {
126- if (a == null || b == null ) throw new NullPointerException ("Arguments must not be null" );
131+ if (a == null || b == null ) {
132+ throw new NullPointerException ("Arguments must not be null" );
133+ }
127134 return a .abs ().gcd (b .abs ());
128135 }
129136
@@ -140,5 +147,4 @@ public static BigInteger gcdBig(long a, long b) {
140147 public static int gcd (int a , int b ) {
141148 return (int ) gcd ((long ) a , (long ) b );
142149 }
143-
144- }
150+ }
0 commit comments