mercredi 16 juin 2021

Split a number into random number of parts where the sum of each part forms the number again

Let's say I have an integer 50. I'm trying to split this into a random number of parts so that the sum of each part form 50 again. E.g, if I split it in 4 parts: 20 + 10 + 15 + 5 = 50.

The split itself and the number of parts will have to be random. How can I achieve this?




Aucun commentaire:

Enregistrer un commentaire