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