|
@@ -1,32 +1,56 @@
|
1
|
|
-
|
2
|
|
-
|
3
|
1
|
|
4
|
2
|
public class NumberUtilities {
|
5
|
|
-
|
6
|
|
- public static String getRange(int start) {
|
7
|
|
- return null;
|
8
|
|
- }
|
9
|
|
-
|
10
|
|
- public static String getRange(int start, int stop) {
|
11
|
|
- return null;
|
12
|
|
- }
|
13
|
|
-
|
14
|
|
-
|
15
|
|
- public static String getRange(int start, int stop, int step) {
|
16
|
|
- return null;
|
17
|
|
- }
|
18
|
|
-
|
19
|
|
- public static String getEvenNumbers(int start, int stop) {
|
20
|
|
- return null;
|
21
|
|
- }
|
22
|
|
-
|
23
|
|
-
|
24
|
|
- public static String getOddNumbers(int start, int stop) {
|
25
|
|
- return null;
|
26
|
|
- }
|
27
|
3
|
|
|
4
|
+ public static String getRange(int stop) {
|
|
5
|
+ String rangeOfNumbers = "";
|
|
6
|
+ for (int i = 0;i < stop; i++){
|
|
7
|
+ rangeOfNumbers = rangeOfNumbers + i;
|
|
8
|
+ }
|
|
9
|
+ return rangeOfNumbers;
|
|
10
|
+ }
|
|
11
|
+
|
|
12
|
+ public static String getRange(int start, int stop) {
|
|
13
|
+ String rangeOfNumbers = "";
|
|
14
|
+ for (int i = start;i < stop; i++){
|
|
15
|
+ rangeOfNumbers = rangeOfNumbers + i;
|
|
16
|
+ }
|
|
17
|
+ return rangeOfNumbers;
|
|
18
|
+ }
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+ public static String getRange(int start, int stop, int step) {
|
|
22
|
+ String rangeOfNumbers = "";
|
|
23
|
+ for (int i = start;i < stop; i += step){
|
|
24
|
+ rangeOfNumbers = rangeOfNumbers + i;
|
|
25
|
+ }
|
|
26
|
+ return rangeOfNumbers;
|
|
27
|
+ }
|
|
28
|
+
|
|
29
|
+ public static String getEvenNumbers(int start, int stop) {
|
|
30
|
+ String evenNumbers="";
|
|
31
|
+ for (int i = start; i < stop; i++)
|
|
32
|
+ if (i % 2 == 0){
|
|
33
|
+ evenNumbers = evenNumbers + i;
|
|
34
|
+ }
|
|
35
|
+ return evenNumbers;
|
|
36
|
+ }
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+ public static String getOddNumbers(int start, int stop) {
|
|
40
|
+ String oddNumbers="";
|
|
41
|
+ for (int i = start; i < stop; i++)
|
|
42
|
+ if (i % 2 != 0){
|
|
43
|
+ oddNumbers = oddNumbers+i;
|
|
44
|
+ } return oddNumbers;
|
|
45
|
+ }
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+ public static String getExponentiations(int start, int stop, int exponent) {
|
|
49
|
+ String exponents="";
|
|
50
|
+ for (int i = start; i <= stop; i++) {
|
|
51
|
+ exponents += (int)Math.pow(i,exponent);
|
|
52
|
+ }
|
|
53
|
+ return exponents;
|
28
|
54
|
|
29
|
|
- public static String getExponentiations(int start, int stop, int exponent) {
|
30
|
|
- return null;
|
31
|
|
- }
|
32
|
55
|
}
|
|
56
|
+}
|