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