Skip to content

Commit

Permalink
Merge pull request #42 from AlphaVS-76/patch-1
Browse files Browse the repository at this point in the history
Create PowerOfFour.java
  • Loading branch information
keshavagarwal17 authored Oct 8, 2021
2 parents ba60ab1 + 19f9bc5 commit e700d25
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 e700d25

Please sign in to comment.