Add code and tests for checking power of 2

This commit is contained in:
Aayushi-Mittal
2021-10-08 15:41:45 +05:30
parent cbf28a7bb2
commit e978f4365d
3 changed files with 680 additions and 82 deletions

View File

@ -0,0 +1,17 @@
/*
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));