|
@@ -17,7 +17,7 @@ public class NumberUtilities {
|
17
|
17
|
|
18
|
18
|
public static String getRange(int start, int stop) {
|
19
|
19
|
String amount = "";
|
20
|
|
- for(int i = 0; start > stop; i++){
|
|
20
|
+ for(int i = 0; start < stop; i++){
|
21
|
21
|
|
22
|
22
|
amount += i;
|
23
|
23
|
|
|
@@ -31,7 +31,7 @@ public class NumberUtilities {
|
31
|
31
|
public static String getRange(int start, int stop, int step) {
|
32
|
32
|
|
33
|
33
|
String amount ="";
|
34
|
|
- for(int i = 0; start > stop; i+=step){
|
|
34
|
+ for(int i = 0; start < stop; i+=step){
|
35
|
35
|
|
36
|
36
|
|
37
|
37
|
amount += i;
|
|
@@ -43,10 +43,13 @@ public class NumberUtilities {
|
43
|
43
|
|
44
|
44
|
public static String getEvenNumbers(int start, int stop) {
|
45
|
45
|
String amount = "";
|
46
|
|
- int j = 2 % stop;
|
47
|
46
|
|
48
|
|
- for(int i = 0; start > stop; i+=j){
|
49
|
|
- amount += i;
|
|
47
|
+
|
|
48
|
+ for(int i = start; i < stop; i++){
|
|
49
|
+ if (i % 2 == 0) {
|
|
50
|
+
|
|
51
|
+ amount += i;
|
|
52
|
+ }
|
50
|
53
|
}
|
51
|
54
|
return amount;
|
52
|
55
|
|
|
@@ -55,10 +58,24 @@ public class NumberUtilities {
|
55
|
58
|
|
56
|
59
|
public static String getOddNumbers(int start, int stop) {
|
57
|
60
|
String amount ="";
|
|
61
|
+
|
|
62
|
+ for(int i = start; i < stop; i++){
|
|
63
|
+ if(i % 3 == 1 ){
|
|
64
|
+ amount += i;
|
|
65
|
+ }
|
|
66
|
+ }
|
|
67
|
+ return amount;
|
|
68
|
+
|
58
|
69
|
}
|
59
|
70
|
|
60
|
71
|
|
61
|
72
|
public static String getExponentiations(int start, int stop, int exponent) {
|
62
|
|
- return null;
|
|
73
|
+ String amount = "";
|
|
74
|
+
|
|
75
|
+ for(int i =start; start < stop; i++){
|
|
76
|
+ amount += (int) Math.pow(start, exponent);
|
|
77
|
+ }
|
|
78
|
+ return amount;
|
|
79
|
+
|
63
|
80
|
}
|
64
|
81
|
}
|