I'm working on a programming project of my own and I'm trying to find the best way to formulate 50 different numbers which add up to a total number. The numbers can't be the same, so I can't simply take the total number and divide by 50. The total number will change each time, but I need all 50 numbers to be different and add up to the total number, whatever it might be. Also, I need the numbers after the decimal to be ignored. I need only whole numbers (the program I'm designing ignores the numbers after the decimal anyway and doesn't round up or down).

**So far, I have worked it out this way, but I'm wondering if there's an easier way:**

Let's say the total number is 1,058,587

1. So to create the first number I take 1,058,587 divided by let's say 75 which = 14114.493, but because my program can't handle decimals and only uses whole numbers, the first number would be 14,114

2. Then I take 1,058,587 minus 14,114 = 1,044,473

3. Then to create the second number, I take 1,044,473 and divide by let's say 89 which = 11735 (without the decimals) and that becomes my second number

I repeat steps 1-3 over and over dividing by different numbers to get 50 different numbers which add up to the total.

For the 50th number, it's okay if it's the remainder.

Is there an easier way and what would the formula look like?

Thanks for any help anyone can provide!