1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
-
-
-
- public class NumberUtilities {
-
- public static String getRange(int stop) {
- String result = "";
- for ( int i = 0; i < stop; i++){
- result+=i;
- }
- return result;
-
-
- }
-
- public static String getRange(int start, int stop) {
- String result="";
- for (int i = start; i< stop; i++){
- result = result+i;
-
- }
- return result;
- }
-
-
- public static String getRange(int start, int stop, int step) {
- String placeNumber = "";
- for (int i = start; i<stop; i = i + step){
- placeNumber= placeNumber + i;
- }
- return placeNumber;
- }
-
- public static String getEvenNumbers(int start, int stop) {
- String resultsProvided = "";
- for (int i = start; i <stop; i++) {
-
- if (i % 2 == 0) {
- resultsProvided = resultsProvided +i;
- }
- }
- return resultsProvided;
- }
-
- public static String getOddNumbers(int start, int stop) {
- String oddNumberReturned = "";
- for(int i = start; i < stop; i++) {
- if(i % 2 != 0){
- oddNumberReturned = oddNumberReturned + i;
- }
- }
- return oddNumberReturned;
- }
-
- public static String getExponentiations(int start, int stop,int exponent) {
- String results = "";
- for (int i = start; i <= stop; i++){
- results = results + (int)Math.pow(i,exponent);
- }
- return results;
- }
- }
|