Description :- Given an integer n, return true if it is a power of two. Otherwise, return false. An…