Leetcode 263. Ugly Number | | Leetcode 263. Ugly Number 文章作者:Tyan博客:noahsnail.com | CSDN | 简书 1. Description 2. Solution1234567891011121314151617181920212223242526class Solution {public: bool isUgly(int num) { if(num <= 0) { return false; } if(num == 1) { return true; } while(num != 1) { if(num % 2 == 0) { num = num / 2; } else if(num % 3 == 0) { num = num / 3; } else if(num % 5 == 0) { num = num / 5; } else { return false; } } return true; }}; Reference https://leetcode.com/problems/ugly-number/description/ 如果有收获,可以请我喝杯咖啡! 赏 微信打赏 支付宝打赏