title: Best way to snap to a value with a min and max?
body: <p>Let's say I have a method as follows:</p>
  <pre><code>public static int snap(int x, int min, int max, int increment) {
      return 0;
  }
  </code></pre>
  <p>x is equal to the value that you want it to snap to
  min is the minimum amount
  max is the maximum amount
  increment is (max - min) / increment</p>
  <p>So let's say x is 27, min is 0, max is 100, and increment is 4</p>
  <p>Then it would return 25 because 100 / 4 = 25 so the 5 possible outcomes would be 0, 25, 50, 75, 100 and 25 is the closest to 27.</p>
  <p>How would I write this method to return this in the most efficient way?</p>