Generate random numbers and count occurrences of 1