Let $f:\mathbb{N} \rightarrow \mathbb{N}$ be defined by $$f(n) = gcd(n,\lfloor \sqrt{n}\rfloor ! \mod n).$$
Show that
a) If $p$ is a prime divisor of $n$ with $p \leq \sqrt{n}$, then $p \mid f(n)$
b) If $p$ is a prime divisor of $n$ with $p \gt \sqrt{n}$, then $p \nmid f(n)$.
The ultimate goal is to show that a natural number $n \geq 2$ is prime iff $f(n) = 1$.
How can I prove this? Can I use the fact that $ gcd(n,\lfloor \sqrt{n}\rfloor ! \mod n) = gcd(n,\lfloor \sqrt{n}\rfloor ! )$ ?
a) Show that $p$ divides both $n$ and $\lfloor \sqrt n \rfloor!$
b) Show that $p$ does not divide both of $n$ and $\lfloor \sqrt n \rfloor!$
For the ultimate goal, if $n$ is prime, then straight-forward calculation shows that $f(n) = 1$. On the other hand, if $n$ is not prime, then it must be divisible by some prime $\leq \sqrt{n}$ (why?), which means that $f(n)$ is divisible by the same prime, and therefore not equal to $1$.