-
-
Notifications
You must be signed in to change notification settings - Fork 291
Expand file tree
/
Copy path326.java
More file actions
25 lines (21 loc) · 753 Bytes
/
326.java
File metadata and controls
25 lines (21 loc) · 753 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
__________________________________________________________________________________________________
sample 10 ms submission
class Solution {
public boolean isPowerOfThree(int n) {
return ( n>0 && 1162261467%n==0);
}
}
__________________________________________________________________________________________________
sample 34036 kb submission
class Solution {
public boolean isPowerOfThree(int n) {
//if(n<3) return false;
while(n>1){
if(n%3!=0) return false;
n=n/3;
}
if(n==1) return true;
return false;
}
}
__________________________________________________________________________________________________