Advertisement
Guest User

Untitled

a guest
Jun 20th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. /**
  2. * @param {number} num
  3. * @return {boolean}
  4. */
  5. var isUgly = function(num) {
  6. let x = num
  7. if(num == 0){
  8. return false;
  9. }
  10. if(num == 1 || num == 2 || num == 3 || num ==5 ){
  11. return true;
  12. }
  13. while(x > 1){
  14. if(x%2 == 0){
  15. x = x / 2
  16. } else if(x % 3 == 0){
  17. x = x / 3
  18. }
  19. else if(x % 5 == 0){
  20. x = x/5
  21. }
  22. else{
  23. return false;
  24. }
  25. }
  26. return true
  27. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement