Skip to content

Commit 05f632b

Browse files
authored
And there was war in heaven
And there was war in heaven: Michael and his angels fought against the dragon; and the dragon fought and his angels (Revelation 12:7)
1 parent ecdaf39 commit 05f632b

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
2+
//And there was war in heaven: Michael and his angels fought against the dragon; and the dragon fought and his angels (Revelation 12:7)
3+
4+
package com.javarush.task.task39.task3910;
5+
6+
/*
7+
isPowerOfThree
8+
*/
9+
public class Solution {
10+
public static void main(String[] args) {
11+
12+
}
13+
14+
public static boolean isPowerOfThree(int n) {
15+
if (n == 0) return
16+
false;
17+
18+
while ((n % 3) == 0) {
19+
n = n / 3;
20+
}
21+
22+
if (n == 1)
23+
return true;
24+
25+
return false;
26+
}
27+
}
28+
29+
/*
30+
isPowerOfThree
31+
32+
Исправь ошибку в методе isPowerOfThree(int n), он должен возвращать true, если n является целочисленной степенью числа 3. Иначе - false.
33+
34+
35+
36+
37+
38+
Требования:
39+
40+
1. Метод isPowerOfThree должен возвращать true, если n является целочисленной степенью числа 3.
41+
42+
2. Метод isPowerOfThree должен возвращать false, если n не является целочисленной степенью числа 3.
43+
44+
3. Метод isPowerOfThree должен быть публичным.
45+
46+
4. Метод isPowerOfThree должен быть статическим.
47+
*/

0 commit comments

Comments
 (0)