jeudi 16 avril 2015

Producing random numbers, which if added equal to a specified number

I'm trying to produce four random numbers between 0 and 100 which will equal to 100.


I've managed to produce the outcome, but it isn't efficient. My method just keeps looping random numbers between 0-100, then adds them, if it doesn't equal to 100 then repeats the process until it equals to 100. Is there a more efficient method?


Thanks in advance





Aucun commentaire:

Enregistrer un commentaire