Here's a groovy solution that gives you the answers you need, you should be able to switch it to any language you use:
def distributedValues(min, max, wanted) { def incrementBy = (max - min)/(wanted + 1) (1..wanted).collect { count -> min + (count * incrementBy) } } assert distributedValues(0, 100, 1) == [50] assert distributedValues(0, 100, 3) == [25, 50, 75] assert distributedValues(0, 100, 4) == [20, 40, 60, 80] assert distributedValues(0, 100, 5) == [16.6666666667, 33.3333333334, 50.0000000001, 66.6666666668, 83.3333333335] assert distributedValues(100, 200, 3) == [125, 150, 175]
source share