Once the told me in the earlier formula, the connection between the items of x and x-1

Once the told me in the earlier formula, the connection between the items of x and x-1

1) How-to find out if certain matter are an electrical power regarding dos ? Imagine a variety N and you ought to select if Letter was an energy off dos. Simple substitute for this problem is to repeated divide N by the dos when the Letter is even. Whenever we have a 1 next Letter are electricity away from 2, if not not. You can find another instance and additionally. In the event that N = 0 it is not an electrical power of 2. Let us code they.

More than means will come back real if x is an electrical power off dos, if you don’t untrue. Time difficulty of your a lot more than password try O(logN).

The same problem can be solved using bit manipulation. Consider a number x that we need to check for being a power for 2. “Once the told me in the earlier formula, the connection between the items of x and x-1” の続きを読む