263. Ugly Number

一定要注意…………审题!!!!

 1     public boolean isUgly(int num) {
 2         if(num <= 0) {
 3             return false;
 4         }
 5         if(num == 1) {
 6             return true;
 7         }
 8         while(num % 2 == 0) {
 9             num /= 2;
10         }
11         while(num % 3 == 0) {
12             num /= 3;
13         }
14         while(num % 5 == 0) {
15             num /= 5;
16         }
17         System.out.println(num);
18         return (num == 1 || num == -1)? true: false;
19     }

 

posted @ 2016-08-13 10:55  warmland  阅读(144)  评论(0编辑  收藏  举报