Title Description:
Write a program to detect if an integer is not 丑数 .
An ugly number is defined as a positive integer that contains only the mass factor 2, 3, 5 . For example, 6, 8 is the ugly number, but 14 is not ugly number thought he contains a quality factor 7.
Precautions
Can be thought of 1 as a special ugly number.
Have you ever encountered this problem in a real interview? Yes
Sample Example
Given num = 8 , return true .
Given num = 14 , return false .
labelMathematical
Topic Analysis:
The remainder of the 2/3/5 is recycled and the quotient can be taken. Yu = 0, the quotient of =1 when the number of ugly.
Source:
Class solution: # @param {int} num an integer # @return {Boolean} true if Num was an ugly number or false def I sugly (self, num): # Write Your code here if num = = 1:return True if num = = 0:return False t = [2,3,5]
i = 0 while True: If i = = 3: return False res = num%t[i] cor = num/t[i] if Cor = = 1 and re s = = 0: return True elif res = = 0: num = num/t[i] continue Else: i + = 1
Lintcode Python Simple Class topic 517. Number of ugly