|
@@ -14,50 +14,50 @@ public class NumberUtilities {
|
14
|
14
|
}
|
15
|
15
|
|
16
|
16
|
public static String getRange(int start, int stop) {
|
17
|
|
- StringBuilder sb2 = new StringBuilder();
|
|
17
|
+ StringBuilder sb = new StringBuilder();
|
18
|
18
|
for(int i = start; i < stop; i++) {
|
19
|
|
- sb2.append(i);
|
|
19
|
+ sb.append(i);
|
20
|
20
|
}
|
21
|
|
- return sb2.toString();
|
|
21
|
+ return sb.toString();
|
22
|
22
|
}
|
23
|
23
|
|
24
|
24
|
|
25
|
25
|
public static String getRange(int start, int stop, int step) {
|
26
|
|
- StringBuilder sb3 = new StringBuilder();
|
|
26
|
+ StringBuilder sb = new StringBuilder();
|
27
|
27
|
for(int i=start; i<stop; i+=step) {
|
28
|
|
- sb3.append(i);
|
|
28
|
+ sb.append(i);
|
29
|
29
|
}
|
30
|
|
- return sb3.toString();
|
|
30
|
+ return sb.toString();
|
31
|
31
|
}
|
32
|
32
|
|
33
|
33
|
public static String getEvenNumbers(int start, int stop) {
|
34
|
|
- StringBuilder sb4 = new StringBuilder();
|
|
34
|
+ StringBuilder sb = new StringBuilder();
|
35
|
35
|
for(int i = start; i < stop; i++) {
|
36
|
36
|
if(i%2==0) {
|
37
|
|
- sb4.append(i);}
|
|
37
|
+ sb.append(i);}
|
38
|
38
|
}
|
39
|
|
- return sb4.toString();
|
|
39
|
+ return sb.toString();
|
40
|
40
|
}
|
41
|
41
|
|
42
|
42
|
|
43
|
43
|
|
44
|
44
|
public static String getOddNumbers(int start, int stop) {
|
45
|
|
- StringBuilder sb5 = new StringBuilder();
|
|
45
|
+ StringBuilder sb = new StringBuilder();
|
46
|
46
|
for(int i = start; i < stop; i++) {
|
47
|
47
|
if(i%2!=0) {
|
48
|
|
- sb5.append(i);}
|
|
48
|
+ sb.append(i);}
|
49
|
49
|
}
|
50
|
|
- return sb5.toString();
|
|
50
|
+ return sb.toString();
|
51
|
51
|
}
|
52
|
52
|
|
53
|
53
|
|
54
|
54
|
public static String getExponentiations(int start, int stop, int exponent) {
|
55
|
|
- StringBuilder sb6 = new StringBuilder();
|
|
55
|
+ StringBuilder sb = new StringBuilder();
|
56
|
56
|
int exp = exponent;
|
57
|
57
|
int answer = 0;
|
58
|
58
|
for(int i=start; i<=stop; i++) {
|
59
|
|
- sb6.append((int)Math.pow(i,exp));
|
|
59
|
+ sb.append((int)Math.pow(i,exp));
|
60
|
60
|
}
|
61
|
|
- return sb6.toString();
|
|
61
|
+ return sb.toString();
|
62
|
62
|
}
|
63
|
63
|
}
|