You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
function power_of_2(n) {
|
|
if (typeof n !== 'number')
|
|
return 'Not a number';
|
|
|
|
return n && (n & (n - 1)) === 0;
|
|
}
|
|
|
|
console.log(power_of_2(16));
|
|
console.log(power_of_2(18));
|
|
console.log(power_of_2(256));
|