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