don't use "x% m" and "x/m" in the same scope. use let (q,r) = core::traits::DivRem::div_rem(x, m);
dont use while x < n; use while x!=n.
use precomputed pow2 table instead of computing 2^k each time
use DivRem(x,2) to check if something is odd or even. Pref divrem over bitwise operation.
dont iterate over full range arrays using indexes. use while let Option::Some(value) = array.pop_front() (or for x in array which is equivalent) or .multi_pop_front< k > to iterate k by k.
do not use while i < data.len(), use let n = data.len(); while i!=n
TLDR :