@@ -0,0 +1,939 @@
+/*%0AGiven an integer, write a function to determine if it is a power of two. %0A*/%0A%0Aimport java.io.*;%0Aimport java.util.*;%0A%0Apublic class PowerofTwo%7B%0A%09public static boolean isPowerOfTwo(int n) %7B%0A        return n %3E 0 && 1073741824 %25 n == 0 ? true: false;  // the biggest power of 2 in integer: 2%5E30%0A        %0A    %7D%0A%09public static boolean isPowerOfTwo2(int n) %7B%0A        int mod = 0;%0A        while(n %3E= 2)%7B%0A            mod = n %25 2;%0A            if(mod != 0) return false;%0A            n = n /2;%0A        %7D%0A        if(n == 1) return true;%0A        return false;%0A    %7D%0A%0A%09%0A%09public static void main(String%5B%5D args) %7B%0A%09%09int%5B%5D nums1 = new int%5B%5D %7B1, 3%7D;%0A%09%09Scanner reader = new Scanner(System.in);  // Reading from System.in%0A%09%09System.out.println(%22Enter a number: %22);%0A%09%09int n = reader.nextInt();%0A%09%09System.out.println(%22is Power of two? %22);%0A%09%09System.out.println(%22method 1:%22 + isPowerOfTwo(n));%0A%09%09System.out.println(%22method 2:%22 + isPowerOfTwo2(n));%0A%09%09return;%0A%09%7D%09%0A%7D%0A

power of two