Mary chose an even 4-digit number $n.$ She wrote down all the divisors of $n$ in increasing order from left to right: $1, 2, \dots, \frac{n}{2}, n.$ At some moment Mary wrote 323 as a divisor of $n.$ What is the smallest possible value of the next divisor written to the right of 323?

324
361
340
646
330

**
This section requires Javascript.
**

You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.

using Mathematica we can easily find all the candidates

`#//.{a___,323,b_,c___}:>{b}&/@Select[Divisors/@(Range[500,4999] 2),!FreeQ[#,323]&]`

which returns

`{{646}, {646}, {646}, {646}, {646}, {646}, {646}, {342}, {340}, {374}, {408}, {442}, {476}, {510}}`