-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSolution.java
More file actions
47 lines (28 loc) · 1.24 KB
/
Solution.java
File metadata and controls
47 lines (28 loc) · 1.24 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//And there was war in heaven: Michael and his angels fought against the dragon; and the dragon fought and his angels (Revelation 12:7)
package com.javarush.task.task39.task3910;
/*
isPowerOfThree
*/
public class Solution {
public static void main(String[] args) {
}
public static boolean isPowerOfThree(int n) {
if (n == 0) return
false;
while ((n % 3) == 0) {
n = n / 3;
}
if (n == 1)
return true;
return false;
}
}
/*
isPowerOfThree
Исправь ошибку в методе isPowerOfThree(int n), он должен возвращать true, если n является целочисленной степенью числа 3. Иначе - false.
Требования:
1. Метод isPowerOfThree должен возвращать true, если n является целочисленной степенью числа 3.
2. Метод isPowerOfThree должен возвращать false, если n не является целочисленной степенью числа 3.
3. Метод isPowerOfThree должен быть публичным.
4. Метод isPowerOfThree должен быть статическим.
*/