human
Check whether a given Number is Power | Python3 program to find whether a number is power - isolated or not.
for 2 as prime factor.
for odd prime factor.
calculate product of powers and prime factors.
check result for power - isolation.
Driver code"
Solution in Python:
 ... Write me a code to check whether a given Number is Power and the other steps required?
assistant
#Here is code to check whether a given Number is Power and the other steps required.
 def checkIfPowerIsolated ( num ) :
	input1 = num ;
	count = 0 ;
	factor = [ 0 ] * ( num + 1 ) ;
	if ( num % 2 == 0 ) :
		while ( num % 2 == 0 ) :
			count += 1 ;
			num //= 2 ;
		factor [ 2 ] = count ;
	i = 3 ;
	while ( i * i <= num ) :
		count = 0 ;
		while ( num % i == 0 ) :
			count += 1 ;
			num //= i ;
		if ( count > 0 ) :
			factor [ i ] = count ;
		i += 2 ;
	if ( num > 1 ) :
		factor [ num ] = 1 ;
	product = 1 ;
	for i in range ( 0 , len ( factor ) ) :
		if ( factor [ i ] > 0 ) :
			product = product * factor [ i ] * i ;
	if ( product == input1 ) :
		print ( " Power - isolated ▁ Integer " ) ;
	else :
		print ( " Not ▁ a ▁ Power - isolated ▁ Integer " ) ;
checkIfPowerIsolated ( 12 ) ;
checkIfPowerIsolated ( 18 ) ;
checkIfPowerIsolated ( 35 ) ;