Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

find if element is powers of 2

    /** Check if a number is a power of 2 or not.
     *  IF n is power of 2, return 1, else return 0.
     */
    int powerOfTwo(int n)
    {
        return n && (!(n & (n-1)));
    }
Source by www.ritambhara.in #
 
PREVIOUS NEXT
Tagged: #find #element #powers
ADD COMMENT
Topic
Name
9+8 =