# Probability of $9$-digit permutation with every $5$-digit subsequence divisible by $3$ or $5$

A nine-digit number is formed using the digit $$1,2,3,4,5,6,7,8,9.$$ Find the probability of forming a number such that product of any of its $$5$$ consecutive digits is divisible by $$3$$ or $$5$$

What I tried

$$A:$$ events in which product of any $$5$$ consecutive digit is divisible by $$3$$

$$B:$$ events in which product of any $$5$$ consecutive digit is divisible by $$5$$

$$P(A\cup B)=P(A)+P(B)-P(A\cap B)$$

let any $$5$$ consecutive digits be $$abcde$$, where $$a,b,c,d,e\in \{1,2,3,\cdots,9\}$$

How do I solve this?

For a set of $$5$$ numbers to have a product that divides either $$3$$ or $$5$$, the set must contain at least one member of the set $$S=\{3,5,6,9\}$$.
So we want to consider permutations of $$9$$ digits where any $$5$$ consecutive digits contains an element of $$S$$.
In other words, we can't have a permutation with a $$5$$ digit sequence without any elements of $$S$$. But, there are only $$5$$ such elements.
So, to count "bad" permutations, we can consider $$V = \{1,2,4,7,8\}$$, as there must be a section of these numbers consecutively. There are $$5!$$ permutations of $$V$$, and then $$4!$$ permutations of $$S$$, and $$5$$ places we can place the block.
So, our final answer is $$1-\frac{5\cdot5!\cdot4!}{9!}$$$$1-\frac{5!5!}{9!}$$$$1-\frac 5{126}=\color{red}{\frac{121}{126}}$$