123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- import java.lang.Math;
-
-
- public class NumberUtilities {
-
- public static String getRange(int start) {
- String answer = "";
- for(int i = 0; i < start; i++){
- String myString = String.valueOf(i);
- answer = answer.concat(myString);
-
- }
-
- return answer;
- }
-
- public static String getRange(int start, int stop) {
- String answer = "";
- for(int i = start; i < stop; i++){
- String myString = String.valueOf(i);
- answer = answer.concat(myString);
-
- }
-
- return answer;
- }
-
-
- public static String getRange(int start, int stop, int step) {
- String answer = "";
-
- for(int i = start; i < stop; i += step){
- String myString = String.valueOf(i);
- answer = answer.concat(myString);
- }
- return answer;
- }
-
- public static String getEvenNumbers(int start, int stop) {
- String answer = "";
-
- for(int i = start; i < stop; i++){
- if(i%2 == 0){
- String myString = String.valueOf(i);
- answer = answer.concat(myString);
- }
- }
- return answer;
- }
-
-
- public static String getOddNumbers(int start, int stop) {
- String answer = "";
-
- for(int i = start; i < stop; i++){
- if(i%2!= 0){
- String myString = String.valueOf(i);
- answer = answer.concat(myString);
- }
- }
- return answer;
- }
-
-
- public static String getExponentiations(int start, int stop, int exponent) {
- String answer = "";
-
- for(int i = start; i <= stop; i++){
- int expo = (int) Math.pow(i, exponent);
- String myString = String.valueOf(expo);
- answer = answer.concat(myString);
-
-
-
-
-
- }
- return answer;
- }
- }
|