12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
-
- import static java.lang.Math.pow;
- public class NumberUtilities {
-
- public static String getRange(int stop) {
- StringBuilder buil=new StringBuilder();
- for(int i=0;i<stop;i++)
- {
- buil.append(i);
- }
-
- return buil.toString();
- }
-
- public static String getRange(int start, int stop) {
- StringBuilder buil=new StringBuilder();
- for(int i=start;i<stop;i++)
- {
- buil.append(i);
- }
-
- return buil.toString();
-
- }
-
- public static String getRange(int start, int stop, int step) {
- StringBuilder buil=new StringBuilder();
-
-
- for(int i=start;i<stop;i=i+step)
- {
- buil.append(i);
- }
-
- return buil.toString();
-
-
- }
-
- public static String getEvenNumbers(int start, int stop) {
- StringBuilder buil=new StringBuilder();
- for(int i=start;i<stop;i++)
- {
- if(i%2==0)
- {
- buil.append(i);
- }
- }
-
- return buil.toString();
- }
-
- public static String getOddNumbers(int start, int stop) {
- StringBuilder buil=new StringBuilder();
- for(int i=start;i<stop;i++)
- {
- if(i%2!=0)
- {
- buil.append(i);
- }
- }
-
- return buil.toString();
- }
-
- public static String getExponentiations(int start, int stop, int exponent) {
- StringBuilder buil=new StringBuilder();
- for(int i=start;i<=stop;i++)
- {
- int k=(int)(Math.pow(i, exponent));
-
- buil.append(k);
-
- }
-
- return buil.toString();
- }
- }
|