ark_ff/fields/
utils.rs

1/// Calculates the k-adicity of n, i.e., the number of trailing 0s in a base-k
2/// representation.
3pub fn k_adicity(k: u64, mut n: u64) -> u32 {
4    let mut r = 0;
5    while n > 1 {
6        if n % k == 0 {
7            r += 1;
8            n /= k;
9        } else {
10            return r;
11        }
12    }
13    r
14}