1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- import java.lang.Math;
-
-
- public class NumberUtilities {
-
- public static String getRange(int start) {
- String output = "";
- for(int i = 0; i < start; i++){
- String number = String.valueOf(i);
- output = output + number;
- }
- return output;
- }
-
- public static String getRange(int start, int stop) {
- String output = "";
- for(int i = start; i < stop; i++){
- String number = String.valueOf(i);
- output = output + number;
- }
- return output;
- }
-
-
- public static String getRange(int start, int stop, int step) {
- String output = "";
- for(int i = start; i < stop; i += step){
- String number = String.valueOf(i);
- output = output + number;
- }
- return output;
- }
-
- public static String getEvenNumbers(int start, int stop) {
- String output = "";
- for(int i = start; i < stop; i ++){
- if(i % 2 == 0){
- String number = String.valueOf(i);
- output = output + number;
- }
- }
- return output;
- }
-
-
- public static String getOddNumbers(int start, int stop) {
- String output = "";
- for(int i = start; i < stop; i ++){
- if(i % 2 == 1){
- String number = String.valueOf(i);
- output = output + number;
- }
- }
- return output;
- }
-
-
- public static String getExponentiations(int start, int stop, int exponent) {
- String output = "";
- for(int i = start; i <= stop; i ++){
- int expNumber = (int) Math.pow(i, exponent);
- String number = String.valueOf(expNumber);
- output = output + number;
- }
- return output;
- }
- }
|