For instance, the smallest non-trivial positive divisor ("sntpd") of $12$ is $2$, the sntpd of $25$ is $5$, the sntpd of $9$ is $3$, etc.
So I'd like to know if there's a formula that given a natural number $n$ ($12$, $25$, and $9$ in the examples) allows me to find its sntpd ($2$, $5$, and $3$ in the examples).