What is the expected number of consecutive digit pairs “23” in a random integer between 1 and 1,000,000?

505 Views Asked by At

had this question on a test and wasn't sure whether my solution is correct. We can use linearity of expectation to look at each two consecutive digits and their expectation for digits 23 as a pair (let this be our random variable X that takes value 1 if a pair is "23" and 0 otherwise) and then sum them up - each pair of digits has "23" as a pair with probability = 0.1*0.1, so expectation for each X1,X2...X5 is = 1 * 0.1 * 0.1 = 0.01 . Since we have 5 such pairs of digits in a number under 1,000,000 (even if number is 23, it is essentially number 000023, so zeros also form pairs of digits, so total number of pairs in each number is still 5), then Expectation [X] = 5 * 0.1 * 0.1 = 0.05. Is my logic (and answer) correct?