12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import java.lang.Math;
  2. public class NumberUtilities {
  3. public static String getRange(int start) {
  4. String sum = "";
  5. for(int i = 0; i < start; i++){
  6. String range = String.valueOf(i);
  7. sum += range;
  8. }
  9. return sum;
  10. }
  11. public static String getRange(int start, int stop) {
  12. String sum = "";
  13. for(int i = start; i < stop; i++) {
  14. String range = String.valueOf(i);
  15. sum += range;
  16. }
  17. return sum;
  18. }
  19. public static String getRange(int start, int stop, int step) {
  20. String result = "";
  21. for(int i = start; i < stop; i += step) {
  22. String range = String.valueOf(i);
  23. result += range;
  24. }
  25. return result;
  26. }
  27. public static String getEvenNumbers(int start, int stop) {
  28. String result = "";
  29. for(int i = start; i < stop; i++) {
  30. if (i % 2 ==0) {
  31. String range = String.valueOf(i);
  32. result += range;
  33. }
  34. } return result;
  35. }
  36. public static String getOddNumbers(int start, int stop) {
  37. String result = "";
  38. for(int i = start; i < stop; i++) {
  39. if(i % 2 ==1){
  40. String range = String.valueOf(i);
  41. result += range;
  42. }
  43. }
  44. return result;
  45. }
  46. public static String getExponentiations(int start, int stop, int exponent) {
  47. String result = "";
  48. for (int i = start; i <= stop; i++){
  49. int stuff = i;
  50. for (int j = 1; j < exponent; j++){
  51. stuff *= i ;
  52. }
  53. result += stuff;
  54. }
  55. return result;
  56. }
  57. }