Is there a function somewhere that divides integer or decimal numbers into parts that are as equal as possible and sum up to the input value?
I'm looking for something that would work like that:
devide(4,2) -> {2,2} (2+2=4, 2 and 2 are equal)
devide(6,4) -> {2,2,1,1} (2+2+1+1=6, no way to make these numbers closer to each other)
I know I can do it myself but I'm looking for some library function.