#NEWLINE# def isUgly( self , num ) : #NEWLINE# #INDENT# '\n        Prime factors: 2, 3, 5\n\n        :type num: int\n        :rtype: bool\n        ' #NEWLINE# if ( num < 1 ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# if ( num == 1 ) : #NEWLINE# #INDENT# return True #NEWLINE# #UNINDENT# ugly = { 2 , 3 , 5 } #NEWLINE# prime = 2 #NEWLINE# while ( ( ( prime * prime ) <= num ) and ( num > 1 ) ) : #NEWLINE# #INDENT# if ( ( num % prime ) != 0 ) : #NEWLINE# #INDENT# prime += 1 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# num /= prime #NEWLINE# if ( prime not in ugly ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( num not in ugly ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# return True