Find most significant set bit of a number | Python program to find MSB number for given n . ; To find the position of the most significant set bit ; To return the value of the number with set bit at k - th position ; Driver code
import math NEW_LINE def setBitNumber ( n ) : NEW_LINE INDENT k = int ( math . log ( n , 2 ) ) NEW_LINE return 1 << k NEW_LINE DEDENT n = 273 NEW_LINE print ( setBitNumber ( n ) ) NEW_LINE