# Counting digits in an arithmetic sequence

Given $a, d, n, x$.

Suggest me a suitable algorithm to compute the number of times the digit $x$ appearing in the arithmetic sequence $a, a + d, a + 2 \times d, \cdots, a + n \times d$.

For example : If $a= 10, d=5,n= 2,x = 0$ the sequence is ($10, 15,20$) so the answer is $2$

Domain specification: $- 1 \le a, n \le 10^9. \text{ and } - 1 \le d \le 20,000.$

-