Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public:
- bool isUgly(int num) {
- if (!num)
- return 0;
- while (!(num % 2))
- num /= 2;
- while (!(num % 3))
- num /= 3;
- while (!(num % 5))
- num /= 5;
- return (num == 1);
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement