Repository navigation
Expand file tree
/
Copy pathKata.java
More file actions
70 lines (60 loc) · 1.39 KB
/
Copy pathKata.java
File metadata and controls
70 lines (60 loc) · 1.39 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
63
64
65
66
67
68
69
70
public class Kata {
public static boolean isEven(int number) {
int result;
result = (number % 2);
if(result == 0) {
return true;
} else {
return false;
}
}
public static boolean isPrimeNumber(int number) {
int counter = 1;
int factorCounter = 0;
while(counter <= number) {
int argumentValue = (number % counter);
if(argumentValue == 0 && counter != 1) {
factorCounter = factorCounter + 1;
}
counter = counter + 1;
}
return (factorCounter == 1 ? true : false);
}
public static int subtract(int firstNumber, int secondNumber) {
int firstValue = (firstNumber - secondNumber);
int secondValue = (secondNumber - firstNumber);
if(firstNumber > secondNumber) {
return firstValue;
} else {
return secondValue;
}
}
public static float divide(int firstNumber, int secondNumber) {
float quotient = (firstNumber / secondNumber);
if(secondNumber == 0) {
return 0;
} else {
} return quotient;
}
public static int factorOf(int number) {
int factorCounter = 0;
int counter = 1;
while(counter <= number) {
int result = (number % counter);
if(result == 0) {
factorCounter = factorCounter + 1;
}
counter = counter + 1;
}
return factorCounter;
}
public static long factorialOf(int number) {
long total = 1;
while(number > 0) {
int result = number--;
total = total * result;
}
return total;
}
public static
}