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