0

I obsever that rand function 1st time always return 41 value.and in defination it say that rand function return random value.

i am so confused please clear this confusion.

6th Nov 2016, 6:12 PM
Shivam Jamaiwar
Shivam Jamaiwar - avatar
2 Respostas
+ 2
Random function are in fact pseudo-random, because true randomness is hard to do. That means they will generate a number given some elements (a seed). That's why most languages ask you to give a seed to the random function, mostly using time (because it always fluctuates). Without giving a seed, you use the default seed, which (apparently) is similar each time you run the random function.
6th Nov 2016, 6:15 PM
Pierre Varlez
Pierre Varlez - avatar
0
A common way to choose a different seed for the random generator is using the current time. Without some seed selection mechanism, the sequence of pseudo-random numbers generated is always the same, as you have already been told.
6th Nov 2016, 6:35 PM
Giulio Pellitta
Giulio Pellitta - avatar