1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
-
- public class NumberUtilities {
-
- public static String getRange(int stop) {
- String rangeOfNumbers = "";
- for (int i = 0;i < stop; i++){
- rangeOfNumbers = rangeOfNumbers + i;
- }
- return rangeOfNumbers;
- }
-
- public static String getRange(int start, int stop) {
- String rangeOfNumbers = "";
- for (int i = start;i < stop; i++){
- rangeOfNumbers = rangeOfNumbers + i;
- }
- return rangeOfNumbers;
- }
-
-
- public static String getRange(int start, int stop, int step) {
- String rangeOfNumbers = "";
- for (int i = start;i < stop; i += step){
- rangeOfNumbers = rangeOfNumbers + i;
- }
- return rangeOfNumbers;
- }
-
- public static String getEvenNumbers(int start, int stop) {
- String evenNumbers="";
- for (int i = start; i < stop; i++)
- if (i % 2 == 0){
- evenNumbers = evenNumbers + i;
- }
- return evenNumbers;
- }
-
-
- public static String getOddNumbers(int start, int stop) {
- String oddNumbers="";
- for (int i = start; i < stop; i++)
- if (i % 2 != 0){
- oddNumbers = oddNumbers+i;
- } return oddNumbers;
- }
-
-
- public static String getExponentiations(int start, int stop, int exponent) {
- String exponents="";
- for (int i = start; i <= stop; i++) {
- exponents += (int)Math.pow(i,exponent);
- }
- return exponents;
-
- }
- }
|