12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
-
- public class NumberUtilities {
- public static String getRange(int stop) {
- String range = new String();
- for(int i = 0; i<stop; i++){
- range = range+i;
- }
- return range;
-
- }
-
- public static String getRange(int start, int stop) {
- String range = new String();
- for (int i=start; i<stop; i++){
- range = range+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();
- if(start % 2 == 1)
- {start +=1;
- }
- for (int i=start;i<stop;i+=2){
- range = range + i;
- }
- return range;
- }
-
- public static String getOddNumbers(int start, int stop) {
- String range = new String();
- for (int i=start;i<stop;i+=2){
- range = range + i;
- }
- return range;
- }
-
- public static String getExponentiations(int start, int stop, int exponent) {
- String range = new String ();
- for(int i=start; i<=stop; i++){
- range = range + ((int)Math.pow(i,exponent));
- }
- return range;
- }
- }
|