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