Factorial under Modular Arithmetic

294 Views Asked by At

The problem is simple: why is it that $$n! = 0 \neq 1 = 0!\mod{}n$$ I would expect $f(n) = f(0) \mod{}n$ for any function $f: \mathbb{Z} \to \mathbb{Z}$.

1

There are 1 best solutions below

3
On BEST ANSWER

$n!$ is a product that involves $n$. As $n \equiv 0 \pmod n$ that product will evaluate to $0 \pmod n$. $0!=1$ because it is the empty product. For your last line, how about $f(n)=\lfloor \frac n2\rfloor$? You need to restrict the class of functions if you want that expectation to be satisfied.