Home > front end >  How to generate X random numbers, where each number is between a range of A and B and the total sum
How to generate X random numbers, where each number is between a range of A and B and the total sum

Time:03-01

I'm trying to code (JavaScript or VB.NET) an algorithm to generate x random numbers. Each random number has to be within a certain range and the total sum of all the numbers has to be equal to a constant. I don't particularly need the exact code (if I do, I can always ask when I start getting into debugging), but just the logic behind the whole thing.

In my particular case: I need to generate 4 random numbers, each between 0 and 10, and the total sum of the randomly generated numbers needs to be 24.

If you need any more information: please ask. Thanks in advance for trying to solve this with me

  • Related