###### [leetcode] 263. Ugly Number

Write a program to check whether a given number is an ugly number.

Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 6, 8 are ugly while 14 is not ugly since it includes another prime factor 7.

Note that 1 is typically treated as an ugly number.

Solution:

class Solution {
public:
bool isUgly(int num) {
if (num<=0) return false;

while(num%2==0 || num%3==0 || num%5==0){
if (num%2==0)
num = num/2;
else if(num%3==0)
num = num/3;
else if(num%5==0)
num = num/5;
}
return num ==1;

}
};

#### leetcode 263 Ugly Number C++

2016-05-23 17:06:43

#### leetcode 263: Ugly Number

2015-08-19 20:17:44

#### [Leetcode-263] Ugly Number（丑陋数）

2015-09-05 10:57:39

#### leetcode_263_Ugly Number(C++)(easy)

2016-04-27 15:39:57

#### LeetCode263——Ugly Number

2015-08-24 21:35:15

#### leetcode笔记：Ugly Number II

2016-01-10 18:42:23

#### 剑指offer 面试题34：寻找丑数(Leetcode 263.ugly number)解题报告

2016-05-07 10:13:47

#### 【LeetCode-263】Ugly Number（C++）

2016-01-16 21:15:31

#### Ugly Number（丑数）系列题 Python解法

2016-05-08 14:27:16

#### [leetcode] 264. Ugly Number II 解题报告

2015-12-13 15:54:50

## 不良信息举报

[leetcode] 263. Ugly Number