|
@@ -3,36 +3,26 @@ package io.zipcoder.microlabs.mastering_loops;
|
3
|
3
|
|
4
|
4
|
public class NumberUtilities {
|
5
|
5
|
public static String getEvenNumbers(int start, int stop) {
|
6
|
|
- int offset = start % 2 != 0 ? 0 : 1;
|
7
|
|
- return getRange(start+offset, stop, 2);
|
|
6
|
+ return null;
|
8
|
7
|
}
|
9
|
8
|
|
10
|
9
|
|
11
|
10
|
public static String getOddNumbers(int start, int stop) {
|
12
|
|
- int offset = start % 2 == 0 ? 0 : 1;
|
13
|
|
- return getRange(start+offset, stop, 2);
|
|
11
|
+ return null;
|
14
|
12
|
}
|
15
|
13
|
|
16
|
14
|
|
17
|
15
|
public static String getSquareNumbers(int start, int stop, int step) {
|
18
|
|
- return getExponentiations(start, stop, step, 2);
|
|
16
|
+ return null;
|
19
|
17
|
}
|
20
|
18
|
|
21
|
19
|
|
22
|
20
|
public static String getRange(int start, int stop, int step) {
|
23
|
|
- String result = "";
|
24
|
|
- for (int i = start; i < stop; i += step) {
|
25
|
|
- result += i;
|
26
|
|
- }
|
27
|
|
- return result;
|
|
21
|
+ return null;
|
28
|
22
|
}
|
29
|
23
|
|
30
|
24
|
|
31
|
25
|
public static String getExponentiations(int start, int stop, int step, int exponent) {
|
32
|
|
- String result = "";
|
33
|
|
- for (int i = start; i < stop; i += step) {
|
34
|
|
- result += (int) Math.pow(i, exponent);
|
35
|
|
- }
|
36
|
|
- return result;
|
|
26
|
+ return null;
|
37
|
27
|
}
|
38
|
28
|
}
|