Divide number by factors
Instead of using mutable variables, it is possible to apply the fold:

let equalsDifference minUnit difference l =
    l
    |&gt; List.fold
        (fun (acc,xs) element -&gt; 
               if acc &lt;&gt; 0m then
                  if difference &lt; 0m then
                     if element &gt;= minUnit then
                         acc + minUnit, (element - minUnit)::xs
                     else
                         acc, element::xs
                  else
                     acc - minUnit, (element + minUnit)::xs
               else
                  acc, element::xs)
        (difference, [])
    |&gt; snd
    |&gt; List.rev