Remainder when dividing biggest prime (with distinct digits) below $100000$ by $37$. Is there any way to find this value in a non-brute-force manner? This question appeared on a timed exam on which one was allowed to use a computer and write programs, but there simply wasn't enough time. My intuition says that the only way is to actually find this prime, but there may exist some mathematical properties I am not aware of.
 A: I think there is not a non-brute-force way to solve your exercise, but the good news is that actually there are not a lot of cases and only in one case there is a prime divisor greater than $19$.
$98765\;$ is divisible by $\;5\;$.
$98764\;$ is divisible by $\;2\;$.
$98763\;$ is divisible by $\;3\;$.
$98762\;$ is divisible by $\;2\;$.
$98761\;$ is divisible by $\;13\;$.
$98760\;$ is divisible by $\;2\;$.
$98756\;$ is divisible by $\;2\;$.
$98754\;$ is divisible by $\;2\;$.
$98753\;$ is divisible by $\;17\;$.
$98752\;$ is divisible by $\;2\;$.
$98751\;$ is divisible by $\;3\;$.
$98750\;$ is divisible by $\;2\;$.
$98746\;$ is divisible by $\;2\;$.
$98745\;$ is divisible by $\;3\;$.
$98743\;$ is divisible by $\;19\;$.
$98742\;$ is divisible by $\;2\;$.
$98741\;$ is divisible by $\;293\;$.
$98740\;$ is divisible by $\;2\;$.
$98736\;$ is divisible by $\;2\;$.
$98735\;$ is divisible by $\;5\;$.
$98734\;$ is divisible by $\;2\;$.
$98732\;$ is divisible by $\;2\;$.
$98731\;$ is prime.
Since $\;98731=2668\cdot37+15\;,\;$ the remainder of the division $\;98731 : 37\;$ is $\;15\;$.
A: According to Empy2's comment, let start $987ab.$
Since $98700  \equiv 0 \pmod{3}$, then exclude $(a,b)$ such that $a+b  \equiv 0 \pmod{3}.$
Further, last digit must be $1$ or $3.$
Let pick up $(a,b)=(6,1),(5,3),(4,1),(4,3),(3,1),(2,3),(1,3)$, then we know $98731$ is prime number.
