human
Write me a code to check whether a given number is an ugly number or not and the other steps required given the following:
Check whether a given number is an ugly number or not | Function to check if a number is an ugly number or not.
Base Cases.
Condition to check if the number is divided by 2 , 3 , or 5.
Driver Code"
How can the above be solved in Python?
assistant
#Here is code to check whether a given number is an ugly number or not and the other steps required.
 def isUgly ( n ) :
	if ( n == 1 ) :
		return 1
	if ( n <= 0 ) :
		return 0
	if ( n % 2 == 0 ) :
		return ( isUgly ( n // 2 ) )
	if ( n % 3 == 0 ) :
		return ( isUgly ( n // 3 ) )
	if ( n % 5 == 0 ) :
		return ( isUgly ( n // 5 ) )
	return 0
if __name__ == " _ _ main _ _ " :
	no = isUgly ( 14 )
	if ( no == 1 ) :
		print ( " Yes " )
	else :
		print ( " No " )