12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
-
- import java.lang.Math;
-
- public class NumberUtilities {
- public static String getRange(int start) {
- String sum = "";
- for(int i = 0; i < start; i++){
- String range = String.valueOf(i);
- sum += range;
- }
- return sum;
- }
-
- public static String getRange(int start, int stop) {
- String sum = "";
- for(int i = start; i < stop; i++) {
- String range = String.valueOf(i);
- sum += range;
- }
-
- return sum;
-
- }
-
- public static String getRange(int start, int stop, int step) {
- String result = "";
- for(int i = start; i < stop; i += step) {
- String range = String.valueOf(i);
- result += range;
- }
- return result;
- }
-
- public static String getEvenNumbers(int start, int stop) {
- String result = "";
- for(int i = start; i < stop; i++) {
- if (i % 2 ==0) {
- String range = String.valueOf(i);
- result += range;
- }
-
- } return result;
- }
-
- public static String getOddNumbers(int start, int stop) {
- String result = "";
- for(int i = start; i < stop; i++) {
- if(i % 2 ==1){
- String range = String.valueOf(i);
- result += range;
- }
- }
- return result;
-
- }
-
- public static String getExponentiations(int start, int stop, int exponent) {
- String result = "";
- for (int i = start; i <= stop; i++){
- int stuff = i;
- for (int j = 1; j < exponent; j++){
- stuff *= i ;
- }
- result += stuff;
- }
- return result;
- }
-
- }
|