-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmisc_skits.java
More file actions
38 lines (33 loc) · 948 Bytes
/
misc_skits.java
File metadata and controls
38 lines (33 loc) · 948 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
26
27
28
29
30
31
32
33
34
35
36
37
38
public class misc_skits {
// get a random number between a - b
// number is multiple of 3;
static int isMultipleof3(int n) {
// if set bits at even - odd position is multiple of 3 then, number is multiple
// of threee
int oddCount = 0, evenCount = 0;
if (n < 0)
n = -n;
if (n == 0)
return 1;
if (n == 1)
return 0;
while (n != 0) {
if ((n & 1) != 0) {
oddCount++;
}
if ((n & 2) != 0) {
evenCount++;
}
n = n >> 2;
}
return isMultipleof3(Math.abs(oddCount - evenCount));
}
public static void main(String[] args) {
System.out.println("dori");
}
private void conversion(String none){
// given long num -> char array
long n1 = 12345678L;
char s[] = Long.toString(n1).toCharArray();
}
}