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