12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
-
-
-
- public class NumberUtilities {
-
- public static String getRange(int start) {
- String range = "";
-
- for (int i = 0; i < start; i++){
- range += i;
- }
-
- return range;
- }
-
- public static String getRange(int start, int stop) {
- String range = new String();
-
- for (int i = start; i < stop; i++){
- 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 = i + step){
- range += i;
- }
- return range;
- }
-
- public static String getEvenNumbers(int start, int stop) {
- String evenNum = new String();
-
- for (int i = start; i < stop; i++){
- if(i % 2 == 0){
- evenNum += i;
- }
- }
-
- return evenNum;
- }
-
-
- public static String getOddNumbers(int start, int stop) {
- String oddNum = new String();
-
- for (int i = start; i < stop; i++){
- if( i % 2 != 0){
- oddNum += i;
- }
- }
-
- return oddNum;
- }
-
-
- public static String getExponentiations(int start, int stop, int exponent) {
- String exponentAns = new String();
-
- for (int i = start; i <= stop; i++){
- int ans = (int)Math.pow(i, exponent);
- exponentAns += ans;
- }
-
- return exponentAns;
- }
- }
|