123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
-
- public class NumberUtilities {
- public static String getRange(int start) {
- String range = "";
- for (int i=0; i<start; i++){
- range = range + Integer.toString(i);
- }
- return range;
- }
-
- public static String getRange(int start, int stop) {
- String range = new String();
- for (int i=start; i<stop; i++){
- range = range + Integer.toString(i);
- }
- return range;
- }
-
- public static String getRange(int start, int stop, int step) {
- String range = new String();
- for (int i=start; i<stop; i+=step){
- range = range + i;
- }
- return range;
- }
-
- public static String getEvenNumbers(int start, int stop) {
- String range = new String();
- for (int i=start; i<stop; i++){
- if (i%2 == 0){
- range = range + i;
- }
- }
- return range;
- }
-
- public static String getOddNumbers(int start, int stop) {
- String range = new String();
- for (int i=start; i<stop; i++){
- if (i%2 == 1){
- range = range + i;
- }
- }
- return range;
- }
-
- public static String getExponentiations(int start, int stop, int exponent) {
- String range = "";
- for (int i=start; i<=stop; i++){
- range = range + (int)Math.pow(i,exponent);
- }
- return range;
- }
- }
|