12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. public class NumberUtilities {
  2. public static String getRange(int stop) {
  3. StringBuilder sb = new StringBuilder();
  4. for(int i=0; i<stop; i++) {
  5. sb.append(i);
  6. }
  7. return sb.toString();
  8. }
  9. public static String getRange(int start, int stop) {
  10. StringBuilder sb = new StringBuilder();
  11. for(int i = start; i < stop; i++) {
  12. sb.append(i);
  13. }
  14. return sb.toString();
  15. }
  16. public static String getRange(int start, int stop, int step) {
  17. StringBuilder sb = new StringBuilder();
  18. for(int i=start; i<stop; i+=step) {
  19. sb.append(i);
  20. }
  21. return sb.toString();
  22. }
  23. public static String getEvenNumbers(int start, int stop) {
  24. StringBuilder sb = new StringBuilder();
  25. for(int i = start; i < stop; i++) {
  26. if(i%2==0) {
  27. sb.append(i);}
  28. }
  29. return sb.toString();
  30. }
  31. public static String getOddNumbers(int start, int stop) {
  32. StringBuilder sb = new StringBuilder();
  33. for(int i = start; i < stop; i++) {
  34. if(i%2!=0) {
  35. sb.append(i);}
  36. }
  37. return sb.toString();
  38. }
  39. public static String getExponentiations(int start, int stop, int exponent) {
  40. StringBuilder sb = new StringBuilder();
  41. int exp = exponent;
  42. int answer = 0;
  43. for(int i=start; i<=stop; i++) {
  44. sb.append((int)Math.pow(i,exp));
  45. }
  46. return sb.toString();
  47. }
  48. }