1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
struct Solution; use std::i32; impl Solution { fn is_power_of_four(mut n: i32) -> bool { while n != 0 && n % 4 == 0 { n /= 4; } n == 1 } } #[test] fn test() { assert_eq!(Solution::is_power_of_four(16), true); }