5 ms·
OK. That algorithm could be improved (for accuracy, not speed) by replacing sums of the smallest number with multiplications as I suppose that multiplication o
by dolmen 5y ago
OK.
That algorithm could be improved (for accuracy, not speed) by replacing sums of the smallest number with multiplications as I suppose that multiplication of more than 3 identical numbers or more is loosing less precision than multiple additions.
For example:
[4, 3, 7, 7, 8] could be calculated as:
(3+4) => [7, 7, 7, 8]
(7*3) => [21, 8]
(8+21) => 29