# Easy-题目19：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.

public class Solution {
public boolean isUgly(int num) {
if(num==0)
return false;

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

return true;
}
}

2ms，beats 18.00%,众数2ms，82.00%
Cmershen的碎碎念：

• 本文已收录于以下专栏：

## LeetCode 263 Ugly Number（丑数）

• NoMasp
• 2016年01月18日 13:24
• 1918

## 20170307-leetcode-263-Ugly Number

1.DescriptionWrite a program to check whether a given number is an ugly number.Ugly numbers are posi...

## Leetcode 263-264 ugly number

Write a program to check whether a given number is an ugly number.Ugly numbers are positive numbers ...

## LeetCode 202. Happy Number & 263. Ugly Number

202. Happy Number Write an algorithm to determine if a number is "happy". A happy number is ...

## LeetCode第264题目 Ugly Number ll

Write a program to find the n-th ugly number. Ugly numbers are positive numbers whose prime facto...

## leetcode263_264：Ugly Number & Ugly Number II

Ugly NumberWrite a program to check whether a given number is an ugly number.Ugly numbers are positi...

## Leetcode 263. Ugly Number & 264. Ugly Number II

263. Ugly Number Total Accepted: 58196 Total Submissions: 157221 Difficulty: Easy Write a pro...

举报原因： 您举报文章：Easy-题目19：263. Ugly Number 色情 政治 抄袭 广告 招聘 骂人 其他 (最多只允许输入30个字)