Divide an integer range into nearly equal integer ranges
<p>I am writing an algorithm that involves taking a set of numbers and putting them into buckets. Can you help me implement these two simple methods? Let me know if I need to explain more.</p>

<pre><code>// return a vector where each element represents the
// size of the range of numbers in the corresponding bucket
// buckets should be equal in size +/- 1
// doesn't matter where the bigger/smaller buckets are
vector&lt;int&gt; makeBuckets(int max, int numberOfBuckets);

// return which bucket n belongs in
int whichBucket(int max, int numberOfBuckets, int n); 
</code></pre>

<p>Example output</p>

<pre><code>makeBuckets(10, 3) == { 3, 3, 4 }; // bucket ranges: (0, 2), (3, 5), (6, 9)
whichBucket(10, 3, 0) == 0;
whichBucket(10, 3, 1) == 0;
whichBucket(10, 3, 2) == 0;
whichBucket(10, 3, 3) == 1;
whichBucket(10, 3, 4) == 1;
whichBucket(10, 3, 5) == 1;
whichBucket(10, 3, 6) == 2;
whichBucket(10, 3, 7) == 2;
whichBucket(10, 3, 8) == 2;
whichBucket(10, 3, 9) == 2;
</code></pre>