Skip to content

Commit

Permalink
Create PowerOfFour.java
Browse files Browse the repository at this point in the history
  • Loading branch information
AlphaVS-76 authored Oct 3, 2021
1 parent 58a8568 commit 19f9bc5
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions PowerOfFour.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
class Solution {

public boolean isPowerOfFour(int n) {
if(n == 0) {
return false;
}

if(n == 1) {
return true;
}

if(n % 4 != 0) {
return false;
}

if(n % 4 == 0) {
return isPowerOfFour(n / 4);
}

return false;
}
}

0 comments on commit 19f9bc5

Please sign in to comment.