Write a function that Given a number, find the most significant bit number which is set bit and which is in power of two
Topic: Write a function that Given a number, find the most significant bit number which is set bit and which is in power of two
Solution
def setBitNumber(n): if (n == 0): return 0 msb = 0 n = int(n / 2) while (n > 0): n = int(n / 2) msb += 1 return (1 << msb)
List all Python Programs