diff --git a/src/data_structures/mmr/utils.cairo b/src/data_structures/mmr/utils.cairo index aa66ac7..6f4bb75 100644 --- a/src/data_structures/mmr/utils.cairo +++ b/src/data_structures/mmr/utils.cairo @@ -89,10 +89,11 @@ fn trailing_ones(n: u32) -> u32 { let mut n = n; let mut count = 0; loop { - if n % 2 == 0 { + let (halfed, rem) = DivRem::div_rem(n, TryInto::>::try_into(2).unwrap()); + if rem == 0 { break count; } - n /= 2; + n = halfed; count += 1; } }