G‑d then instructed Moses to count the people and animals that had been captured from the Midianites. The soldiers were allowed to keep half and the other half was to be given to the rest of the Jewish people. The soldiers then had to give 1/500th of their half to the priests, and the people had to give 1/50th of their half to the Levites. Moses followed G‑d’s instructions, counting the captured people and animals and then dividing them up and giving the priests and Levites their portions.
Divine Assistance
וַיְהִי הַמַּלְקוֹחַ וגו': (במדבר לא:לב)
The plunder consisted of. . . . Numbers 31:32

When the soldiers counted the captured people and animals, they found that miraculously, the totals were all divisible by 50 and by 500. This made it possible for them to follow G‑d’s instructions regarding the exact percentages of what they had captured to be given to the priests and Levites. This was all the more remarkable considering all the factors that had to contribute to this miracle: the fertility and lifespan of the people and animals, etc., all of which took place long before they were captured in battle.

From this, we learn that we should never be fazed by any seeming obstacle in fulfilling G‑d’s directives or accomplishing our Divine mission. Rather, we should recall that G‑d has arranged matters long in advance to enable us to accomplish our Divine goals in the most optimal manner possible.1