I have 4 functions
\begin{align} f_1(x) &= x \text{ mod } 1\\ f_2(x) &= x \text{ mod } 3 \\ f_3(x) &= x \text{ mod } 4 \\ f_4(x) &= x \text{ mod } 12\\ \end{align}
for $x \in [0,\infty) $
I want to create a function $g(x)$ that counts the number of zeroes at $x$ for those four functions.
For example, $x=6$ would have
\begin{align} f_1(6) &= 0\\ f_2(6) &= 0 \\ f_3(6) &= 2 \\ f_4(6)& = 6 \\ \end{align}
Since only two of these are zero, then $g(6) = 2$
Another example is $x=24$
\begin{align} f_1(24) &= 0\\ f_2(24) &= 0 \\ f_3(24) &= 0 \\ f_4(24)& = 0\\ \end{align}
Since all four of these are 0, then $g(24) = 4$
If $x =0.5$, then
\begin{align} f_1(0.5) &= 0.5 \\ f_2(0.5)& = 0.5 \\ f_3(0.5) &= 0.5\\ f_4(0.5) &= 0.5 \\ \end{align}
Since none of these are zero, then $g(0.5)=0$
How can I define $g(x)$ elegantly?
Inelegant method I've found
One inelegant way I thought of was basically count them for each possible value.
\begin{align} g(0)& = 4 \\ g(1) &= 1 \\ g(2)& = 1\\ g(3)& = 2 \\ g(4)& = 2 \\ g(5)& = 1\\ g(6)& = 2 \\ g(7)& = 1\\ g(8)& = 2\\ g(9) &= 2 \\ g(10) &= 1\\ g(11)& = 1\\ \end{align}
Then for any $x$, I could do $g(x \text{ mod } 12)$ and it would either match one of these or else $g(x) = 0$.
This gives me the correct result. However, this seems very inelegant and I'm hoping for a nicer solution.