1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
-
-
-
- public class NumberUtilities {
-
- public static String getRange(int stop) {
- StringBuilder builder = new StringBuilder();
- for(int i=0; i<stop; i++){
- builder.append(i);
- }
- return builder.toString();
- }
-
- public static String getRange(int start, int stop) {
- StringBuilder builder = new StringBuilder();
- for(int i=start; i<stop; i++){
- builder.append(i);
- }
- return builder.toString();
- }
-
-
- 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.toString();
- }
-
- 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.toString();
- }
-
-
- 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.toString();
- }
-
-
- public static String getExponentiations(int start, int stop, int exponent) {
- StringBuilder builder = new StringBuilder();
- for(int i=start; i<=stop; i++){
- int result = (int)(Math.pow(i,exponent));
- builder.append(result);
- }
- return builder.toString();
- }
- }
|