1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
struct Solution; impl Solution { pub fn is_ugly(mut n: i32) -> bool { if n == 0 { return false; } for i in vec![2,3,5] { while n % i == 0 { n /= i; } } n == 1 } } fn main() { print!("{}", Solution::is_ugly(6)); }