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.

Example 1:


Input: 6
Output: true
Explanation: 6 = 2 × 3

Example 2:


Input: 8
Output: true
Explanation: 8 = 2 × 2 × 2


Example 3:


Input: 14
Output: false 
Explanation: 14 is not ugly since it includes another prime factor 7.


Note:


       1 is typically treated as an ugly number.
       Input is within the 32-bit signed integer range: [−231,  231 − 1].

Difficulty: EASY
Starter code: class Solution:
    def isUgly(self, num: int) -> bool:
        

Solutions:
class Solution:

	def isUgly(self, num):
		if num < 1:
			return False
		while num % 2 == 0:
			num = num / 2
		while num % 3 == 0:
			num = num / 3
		while num % 5 == 0:
			num = num / 5
		if num == 1:
			return True
		else:
			return False


class Solution:

	def isUgly(self, num):
		if num == 0:
			return False
		for d in (5, 3, 2):
			while num % d == 0:
				num //= d
			if num == 1:
				break
		else:
			return False
		return True


class Solution:

	def isUgly(self, num):
		n = num
		if n < 1:
			return False
		elif n == 1:
			return True
		else:
			while n >= 1:
				ncount = 0
				if n % 3 == 0:
					n = n // 3
					ncount = 1
				if n % 2 == 0:
					n //= 2
					ncount = 1
				if n % 5 == 0:
					n //= 5
					ncount = 1
				if ncount == 1:
					pass
				else:
					break
			if n == 1:
				return True
			else:
				return False


class Solution:

	def isUgly(self, num):
		lst = []
		if num < 1:
			return False
		if num == 1:
			return True
		i = 2
		while i < num + 1:
			print(num, i, ' ', lst)
			if num % i == 0:
				if i not in [2, 3, 5]:
					lst.append(i)
					if lst != []:
						return False
				num = num // i
			else:
				i += 1
				if i > 5:
					return False
		if lst == []:
			return True


class Solution:

	def isUgly(self, num):
		if num <= 0:
			return False
		for i in [2, 3, 5]:
			while num % i == 0:
				num = num // i
		return num == 1


class Solution:

	def isUgly(self, num):
		if num <= 0:
			return False
		elif num == 1:
			return True
		for factor in (5, 3, 2):
			while num % factor == 0:
				num = num / factor
				print(num)
		return int(num) == 1


class Solution:

	def isUgly(self, num):
		for p in [2, 3, 5]:
			while num % p == 0 < num:
				num /= p
		return num == 1


class Solution:

	def isUgly(self, num):
		if num <= 0:
			return False
		count = 0
		while count == 0:
			num = num / 2
			if str(num)[-1] != '0':
				print(11)
				count = 1
				num = num * 2
		count = 0
		while count == 0:
			num = num / 3
			if str(num)[-1] != '0':
				count = 1
				num = num * 3
		count = 0
		while count == 0:
			num = num / 5
			if str(num)[-1] != '0':
				count = 1
				num = num * 5
		if num != 1.0:
			return False
		else:
			return True