[Math] Probability of product of 5 digits being divisible by 5 or 7.

combinationspermutationsprobability

Seven digit numbers are formed using digits 1,2,3,4,5,6,7,8,9 without repetition. The probability of selecting a number such that product of any 5 consecutive digits is divisible by either 5 or 7 is p. Then 12p is equal to ?

The answer is 7.

I tried many different ways that I could think of but am unable to get an answer.

Please help!!!1

Best Answer

I'm interpreting "divisible by either $5$ or $7$" as "divisible by at least one of $5$ or $7$".

We have to build a random injective word of length $7$ over the alphabet $[9]$. Let us compute the probability $q:=1-p$ that some subsequence of five entries contains neither the letter $5$ nor the letter $7$. Such a sequence exists iff at none of the positions $3$, $4$, $5$ of the word we have one of $5$ or $7$. There are $9\cdot8\cdot 7$ equiprobable ways to fill these positions, and $7\cdot 6\cdot 5$ of them contain neither $5$ nor $7$. It follows that $q={30\over72}$, hence $p={42\over72}$, and $12p=7$.