Find minimum distribution value for percentage

35 Views Asked by At

I need a formula for below requirement. I have a set of users. The user count is dynamic. That is, it can be any number. For Ex, I have 5 users. For each users, I need to distribute the books by the percentage set for the users. For ex:

User 1 = 15%
User 2 = 15%
User 3 = 10%
User 4 = 30%
User 5 = 30%

The sum of percentage of all users will be 100 always. My question is, we need to get the minimum variation to distribute the books to the users. In my example, the minimum variation is 20. If we have 20 Books, we can share the books as 3, 3, 2, 6, 6. I need a FORMULA to find this minimum value. Since I'm very poor in mathematics, I didn't know the correct term. Here user count and the percentage for each user will vary. Can someone help me to find the formula for the same??

Thanks in advance!

1

There are 1 best solutions below

4
On

Find the greatest common divisor of the percentages. In your case it is $5$. Divide that into each of them to get the number of books to give each one.