12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- import static java.lang.Math.pow;
-
-
- public class NumberUtilities {
-
- public static String getRange(int start) {
-
- String s="";
-
- for(int i =0; i < start; i++)
- {
- s = s +i;
- }
- return s;
- }
-
- public static String getRange(int start, int stop) {
- String s2 = "";
- for(int i = start; i<stop; i++)
- {
- s2 = s2 + i;
- }
- return s2;
- }
-
-
- public static String getRange(int start, int stop, int step) {
- String s3 = "";
- for(int i = start; i < stop; i+=step)
- {
- s3 = s3 +i;
- }
- return s3;
- }
-
- public static String getEvenNumbers(int start, int stop) {
- String s4 = "";
- for(int i = start; i < stop; i++)
- {
- if((i&1)==0)
- {
- s4+=i;
- }
- }
-
- return s4;
- }
-
-
- public static String getOddNumbers(int start, int stop) {
- String s5 = "";
- for(int i = start; i<stop; i++)
- {
- if((i&1)!=0)
- {
- s5+=i;
- }
- }
-
- return s5;
- }
-
-
- public static String getExponentiations(int start, int stop, int exponent) {
- String s6="";
-
- for(int i = start; i <= stop; i++)
- {
- s6 = s6 + (int)Math.pow(i, exponent);
-
- }
-
- return s6;
- }
- }
|