if you are given three numbers B,M and X i want to check if the statement is true or false:

any number in B-system with M digits(where as the digits are consecutive numbers in any row) will be divided by X..
example if B=10, M=3 , X=3
this is true because every number with 3 consecutive digits can be divide by X=3 (for example 765, 432,867, 123, 231...)

2<=B<=1024
1<=M<=1024
1<=X<=1024

any ideas for a good algorithm??
ps. it is not a good idea to try to find all the numbers(about M!) because there are so many