Skip to content
Advertisement

How to insert random values in an array with max lenght and max array sum [closed]

So, i need to make an array with lets say $n = 100 (max array length) and $target = 50 (max array values sum) with random numbers between 0-20.

I’ve tried with the below code but it gets – values when y<x.

JavaScript

Advertisement

Answer

You can try next code as approach:

JavaScript

Here you can try it: PHPize.online

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement