1 //create a boolean method that checks if number is a power of 2 by using modulus
2public static boolean powerOfTwoGeneral(int n)
3 {
4 while(n%2==0)
5 {
6 n=n/2;
7 }
8 if(n==1)
9 {
10 return true;
11 }
12 else
13 {
14 return false;
15 }
16 }
17
18