For a given number $n$ I want to find the lowest integer multiple of $n$ that is represented in decimal as the following regular expression: $[4]^+[0]^*$
Examples of numbers that are generated by that regex are: 4, 40, 44, 400, 440, 444
Notice that 404 is not a member.
So far what I figured out experimentally is that for a given number $n$ composed of two prime factors $p_1$ and $p_2$ the number of $4$s is $(p_1-1)(p_2-1)/2$.
Does anyone know an exact formula for figuring out the number of $4$s and $0$s in the minimum multiple described above?
First, factor $n$ into $2^a5^bc$ The number of zeros will be $\max(a-2,b)$ where the $-2$ comes from the $4$s in your number. The number of $4$s will be the length of the repeat in the decimal of $\frac 1c$, which is the minimum $k$ such that $10^k \equiv 1 \pmod c$ except that if you have a factor of $3$ you multiply by $3$ and if you have a factor $9$ you multiply by $9$.