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