human
Can you provide a code to check whether a number has consecutive 0 's in the given base or not and the other steps required given the following:
Check whether a number has consecutive 0 's in the given base or not | We first convert to given base , then check if the converted number has two consecutive 0 s or not.
Function to convert N into base K.
Weight of each digit.
Function to check for consecutive 0.
Flag to check if there are consecutive zero or not.
If there are two consecutive zero then returning False.
Driver code"
Solution in Python:
assistant
#Here is code to check whether a number has consecutive 0 's in the given base or not and the other steps required.
 def hasConsecutiveZeroes ( N , K ) :
	z = toK ( N , K )
	if ( check ( z ) ) :
		print ( " Yes " )
	else :
		print ( " No " )
def toK ( N , K ) :
	w = 1
	s = 0
	while ( N != 0 ) :
		r = N % K
		N = N // K
		s = r * w + s
		w * = 10
	return s
def check ( N ) :
	fl = False
	while ( N != 0 ) :
		r = N % 10
		N = N // 10
		if ( fl == True and r == 0 ) :
			return False
		if ( r > 0 ) :
			fl = False
			continue
		fl = True
	return True
N , K = 15 , 8
hasConsecutiveZeroes ( N , K )