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


2 Answers 2


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$.

  • $\begingroup$ See here for more discussion. The claim made in this answer that a sequence has the property that some subsequence of 5 entries containing neither 5 nor 7 if and only if positions 3,4,5 all do not contain 5 or 7 is false. Consider the sequence 5234176 which has in those positions 341. $\endgroup$
    – JMoravitz
    Apr 24, 2023 at 14:16


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.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .