for(int j=0;j<2;j++)
{
for(int i=0;i<3276800;i++)
{
cout<<(rand()%2)<<\'\\n\';
}
cout<
The firs
The RNG used by most implementations of rand
is a linear congruential generator. These tend to have very poor periods in the low-order bits; very naive implementations may have a period of just 2 in the low order bit (i.e. alternating 0 and 1).
Better implementations return only the high 16 bits of the random value, discarding the poor-quality low-order bits. In such an implementation, the low-order bit will have period at most 2^16 = 65536. Since 65536 divides 3276800 evenly, you will see a periodic pattern.