Find whether a given number is a power of 4 or not | Python3 program to check if given number is power of 4 or not ; Driver code
import math NEW_LINE def isPowerOfFour ( n ) : NEW_LINE INDENT return ( n > 0 and 4 ** int ( math . log ( n , 4 ) ) == n ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT test_no = 64 NEW_LINE if ( isPowerOfFour ( test_no ) ) : NEW_LINE INDENT print ( test_no , " ▁ is ▁ a ▁ power ▁ of ▁ 4" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( test_no , " ▁ is ▁ not ▁ a ▁ power ▁ of ▁ 4" ) NEW_LINE DEDENT DEDENT