forked from yennanliu/CS_basics
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhello.java
More file actions
62 lines (50 loc) · 1.42 KB
/
hello.java
File metadata and controls
62 lines (50 loc) · 1.42 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package dev;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public class hello {
public static void main(String[] args) {
//System.out.println("hello!");
//
// Integer[] _array = new Integer[4];
// _array[0] = 10;
// _array[1] = -2;
// _array[2] = 0;
// _array[3] = 99;
// Arrays.stream(_array).forEach(System.out::println);
// Arrays.sort(_array, Collections.reverseOrder());
// System.out.println("---");
// Arrays.stream(_array).forEach(System.out::println);
//
// System.out.println("--->");
//
// List<Integer> _list = Arrays.asList(1,2,3,4);
// _list.forEach(System.out::println);
// Collections.sort(_list, Collections.reverseOrder());
// System.out.println("---");
// _list.forEach(System.out::println);
//System.out.println(20 / 8);
hello h = new hello();
System.out.println(">>> isUgly(12) = " + h.isUgly(12));
}
private boolean isUgly(int x){
if(x == 1){
return true;
}
// ??
while(x > 1){
if(x % 2 == 0){
x = (x / 2);
}
else if(x % 3 == 0){
x = (x / 3);
}
else if(x % 5 == 0){
x = (x / 5);
}else{
return false; // ???
}
}
return true;
}
}