-1
I noticed that if I use the Math.random
with values from 0 to 10, it is very possible that the result will be repeated or generate an approximate value of the previous.
For example, I executed:
function random() {
return Math.floor(Math.random() * 10);
}
and left:
If it exists, how do I generate even more random values?
Based on what do you claim that Math.Random() is not random enough? Strong claims like this call for strong evidence. What tests have you done, besides printing half a dozen samples? Which Javascript implementation are you testing and claim to be bad?
– epx
good, for what I’m trying to do, really it’s not, I put the function
random
upstairs for you to test. I’m not saying it’s bad, I just want to prevent repeated numbers from being displayed less frequently, because the lower the maximum number, the more likely it is to be repeated frequently– EduApps
The way you did, it will only generate numbers between 0 and 9, so of course after a few runs you will get repeat, and the more times you run, the more chances you will repeat. What exactly do you want to do?
– hkotsubo
wanted to have a larger variation if it ran again
– EduApps