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