Skip to content

Latest commit

 

History

History
27 lines (22 loc) · 426 Bytes

263丑数.md

File metadata and controls

27 lines (22 loc) · 426 Bytes

这题的收获,不要想太偏门。。。

public boolean isUgly(int num) {
    if(num == 1) {
        return true;
    }
    if(num == 0) {
        return false;
    }
    while(num % 2 == 0) {
        num >>= 1;
    }
    while(num % 3 == 0) {
        num /= 3;
    }
    while(num % 5 == 0) {
        num /= 5;
    }
    return num == 1;
}