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 {
4let mut r = 0;
5while n > 1 {
6if n % k == 0 {
7 r += 1;
8 n /= k;
9 } else {
10return r;
11 }
12 }
13 r
14}