I'm playing around with rand() and srand() functions and I was trying to make a counter for how many 1's I could get in a row with a 50/50 generator, yet it seems that it caps out at 15 numbers in a row.
#include <cstdlib>
#include <ctime>
using namespace std;
int main() {
int MostInARow = 0, CurrentInARow;
bool randomised;
srand((int)time(NULL));
for (long int i = 0; i < 100000000; i++) {
CurrentInARow = 0;
randomised = rand() % 2;
while (randomised) {
randomised = rand() % 2;
CurrentInARow++;
}
if (CurrentInARow > MostInARow) {
system("CLS");
MostInARow = CurrentInARow;
cout << MostInARow;
}
}
return 0;
}
I'd love to learn why this happens.