We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7dfe84e commit 08890bcCopy full SHA for 08890bc
1 file changed
src/test/java/com/thealgorithms/bitmanipulation/PowerOfFour.java
@@ -0,0 +1,16 @@
1
+package com.thealgorithms.bitmanipulation;
2
+
3
+public class PowerOfFour {
4
5
+ private PowerOfFour() {
6
+ throw new IllegalStateException("Utility class");
7
+ }
8
9
+ public static boolean isPowerOfFour(int n) {
10
+ if (n <= 0) {
11
+ return false;
12
+ } else {
13
+ return (n & (n - 1)) == 0 && (n & 0x55555555) != 0;
14
15
16
+}
0 commit comments