-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathIsEven.java
114 lines (87 loc) · 2.5 KB
/
IsEven.java
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
package com.rotatingcow;
import java.io.IOException;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Mode;
public class IsEven {
static Integer num = 300000000;
public static void main(String[] args) {
try {
org.openjdk.jmh.Main.main(args);
} catch (IOException e) {
e.printStackTrace();
}
for(Integer i = 0; i< 100; i++){
System.out.println(isEven(Integer.valueOf(i.toString().substring(i.toString().length()-1))));
}
}
static boolean isEven(int num){
if(num == 0 ){
return true;
}else if(num == 1){
return false;
}else if(num < 2){
return (isEven(-num));
}else{
return isEven(num-2);
}
}
static boolean isOdd(int num){
return(isEven(num+1));
}
static boolean isNotEven(int num){
return !isEven(num);
}
static boolean isNotOdd(int num){
return !isOdd(num);
}
static boolean wasEven(int num, int addend){
num += addend;
return(isEven(num - addend) && isDivisibleByTwo(num - addend) && isEvenAndNotOdd(num - addend) && isOddOrEven(num - addend));
}
static boolean wouldBeEven(int num){
return isEven(num+1);
}
static boolean isOddOrEven(int num){
return(isOdd(num) || isEven(num));
}
static boolean isNotOddOrNotEven(int num) {
return(isNotOdd(num) || isNotEven(num));
}
static boolean isOddAndEven(int num){
return(isOdd(num) && isEven(num));
}
static boolean isNotOddAndNotEven(int num){
return (isNotOdd(num) && isNotEven(num));
}
static boolean isEvenAndNotOdd(int num){
return(isEven(num) && isNotOdd(num));
}
static boolean isOddAndNotEven(int num){
return(isOdd(num) && isNotEven( num));
}
static boolean isDivisibleByTwo(int num){
return(num % 2 == 0);
}
static boolean isTheOriginalEven(int num){
return (num == 2);
}
static boolean isNotTheOriginalEven(int num) {
return (num != 2);
}
static boolean isSuperEven(int num) {
return false;
}
static boolean isEven(String num){
return false;
}
static boolean isOdd(String num){
return false;
}
static boolean isEven(boolean num){
return false;
}
static boolean isOdd(boolean num){
return false;
}
}