SHARE
TWEET

Untitled

a guest Nov 20th, 2019 98 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  /**
  2.    * Given a min and a max, return a list of numbers that are divisible by five
  3.    * or six, but not both. The line will wrap after 10 numbers.
  4.    * <pre>
  5.    * numbersThatAreDivisibleByFiveOrSixButNotBoth(23, 38) ->
  6.    *                                       "24,25,35,36,"
  7.    * </pre>
  8.    * @param min
  9.    * @param max
  10.    * @return
  11.    */
  12.   public static String numbersThatAreDivisibleByFiveOrSixButNotBoth(int min, int max) {
  13.     String response = "";
  14.     int length = 0;
  15.     int i = min;
  16.     while (i != max) {
  17.         if ((i % 5 == 0 && i % 6 != 0) || (i % 5 != 0 && i % 6 == 0)) {
  18.             response+= i + ",";
  19.          }
  20.         if (length % 10 == 0 && length != 0) {
  21.             response += ("\n");
  22.         }
  23.         i++;
  24.     }
  25.     return response;
  26.  
  27.   }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top