title: Delphi Division with equal splitting of the rest (MOD)
body: <p>I have a math question which I try to solve with a Delphi function. I am trying to split up an integer into (nearly) equal pieces. Example:</p>
  
  <p>You have 10 testcases and you want to execute them in 3 parts. So the best way to balance the workload would be to execute 3, 3, and 4 rather than 1, 1 and 8.</p>
  
  <pre><code>procedure calc_stream_numbers;
  var div_res,rest:double;
      total,streams:integer;
  begin
  total := 10; 
  streams := 3;
   div_res := total DIV streams;
   rest := total MOD streams;
   showmessage('Items: '  +IntToStr(total)+#13#10+
                'Streams: '+IntToStr(streams)+#13#10+
                'Result: '+FloatToStr(div_res)+
                'Rest: '+FloatToStr(rest));
  end;
  </code></pre>
  
  <p>This gives me the division result of 10 / 3 = 3 (Rest 1) So I could execute 3 x 3 Testcases which makes 9 in total. To execute all 10 of them, I have to add the remaining one to any of the 3 streams. But If you have a more complicated example..</p>
  
  <p>I am sure there is a mathematical expression for this but I must admit, I have noe clue. Maybe you are able to enlighten me how such a division is called and if there is any built-in delphi function.</p>