12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- import java.lang.*;
-
-
- public class NumberUtilities {
-
- public static String getRange(int stop) {
- String str = "";
- for(int i = 0; i < stop; i++)
- {
- str = str.concat(Integer.toString(i));
- }
- return str;
- }
-
- public static String getRange(int start, int stop) {
- String str = "";
- for(int i = start; i < stop; i++)
- {
- str = str.concat(Integer.toString(i));
- }
- return str;
- }
-
- public static String getRange(int start, int stop, int step) {
- String str = "";
- for(int i = start; i < stop; i += step)
- {
- str = str.concat(Integer.toString(i));
- }
- return str;
- }
-
-
- public static String getEvenNumbers(int start, int stop) {
- int startEven = (start % 2 != 0) ? start + 1 : start;
- String str = "";
- for(int i = startEven; i < stop; i += 2)
- {
- str = str.concat(Integer.toString(i));
- }
- return str;
- }
-
- public static String getOddNumbers(int start, int stop) {
- int startOdd = (start % 2 == 0) ? start + 1 : start;
- String str = "";
- for(int i = startOdd; i < stop; i += 2)
- {
- str = str.concat(Integer.toString(i));
- }
- return str;
- }
-
-
- public static String getExponentiations(int start, int stop, int exponent) {
- String str = "";
- double exponentD = exponent;
- int tempInt;
- for(double i = start; i <= stop; i++)
- {
- tempInt = (int)(Math.pow(i, exponentD));
- str = str.concat(Integer.toString(tempInt));
- }
- return str;
- }
- }
|