mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-14 18:03:53 +08:00
17 lines
278 B
JavaScript
17 lines
278 B
JavaScript
/*
|
|
author: @Aayushi-Mittal
|
|
|
|
This script will check whether the given
|
|
number is a power of two or not.
|
|
|
|
*/
|
|
|
|
export const IsPowerOfTwo = (n) => {
|
|
if ((n&(n-1))==0 && n!=0)
|
|
return true;
|
|
else
|
|
return false;
|
|
}
|
|
|
|
// console.log(IsPowerOfTwo(0));
|
|
|