# Probability of product of 5 digits being divisible by 5 or 7.

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 ?

I tried many different ways that I could think of but am unable to get an 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$.

HINT:

Since $5$ is prime, for the product $5$ consecutive digits to be divisible by $5$, clearly the digit $5$ needs to be one of those digits.

The same goes for $7$.

So, the question can be rephrased as: What is the probability that if you create a $7$ digit number in the way as described, any five consecutive digits of that number contain either a $5$ or a $7$?

And, to answer that question, it is probably easiest to calculate the probability of that $7$ digit number contain some sequence of five consecutive digits that does not contain a $5$ or a $7$, and subtract that from $1$ to get your answer.