Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * @param {number} num
- * @return {boolean}
- */
- var isUgly = function(num) {
- let x = num
- if(num == 0){
- return false;
- }
- if(num == 1 || num == 2 || num == 3 || num ==5 ){
- return true;
- }
- while(x > 1){
- if(x%2 == 0){
- x = x / 2
- } else if(x % 3 == 0){
- x = x / 3
- }
- else if(x % 5 == 0){
- x = x/5
- }
- else{
- return false;
- }
- }
- return true
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement