File tree Expand file tree Collapse file tree 1 file changed +6
-8
lines changed
Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Original file line number Diff line number Diff line change @@ -274,20 +274,19 @@ macro_rules! impl_integer_for_isize {
274274 n = n. abs( ) ;
275275
276276 // divide n and m by 2 until odd
277- n >>= n. trailing_zeros( ) ;
278277 m >>= m. trailing_zeros( ) ;
278+ n >>= n. trailing_zeros( ) ;
279279
280- loop {
280+ while m != n {
281281 if m > n {
282282 m -= n;
283- if m == 0 { return n << shift; }
284283 m >>= m. trailing_zeros( ) ;
285284 } else {
286285 n -= m;
287- if n == 0 { return m << shift; }
288286 n >>= n. trailing_zeros( ) ;
289287 }
290288 }
289+ m << shift
291290 }
292291
293292 /// Calculates the Lowest Common Multiple (LCM) of the number and
@@ -540,20 +539,19 @@ macro_rules! impl_integer_for_usize {
540539 let shift = ( m | n) . trailing_zeros( ) ;
541540
542541 // divide n and m by 2 until odd
543- n >>= n. trailing_zeros( ) ;
544542 m >>= m. trailing_zeros( ) ;
543+ n >>= n. trailing_zeros( ) ;
545544
546- loop {
545+ while m != n {
547546 if m > n {
548547 m -= n;
549- if m == 0 { return n << shift; }
550548 m >>= m. trailing_zeros( ) ;
551549 } else {
552550 n -= m;
553- if n == 0 { return m << shift; }
554551 n >>= n. trailing_zeros( ) ;
555552 }
556553 }
554+ m << shift
557555 }
558556
559557 /// Calculates the Lowest Common Multiple (LCM) of the number and `other`.
You can’t perform that action at this time.
0 commit comments