Pick a number, and we'll show every width × height rectangle grid it can exactly fill. The side lengths of those rectangles are exactly its divisors.
Why draw rectangles to find divisors? The reason is simple — if an n-square grid can be exactly filled with a rows and b columns, that means a×b=n, so both a and b are divisors of n. So "finding every rectangle that fits exactly" and "finding every divisor" turn out to be the same problem.
The fun part is that these rectangles always come in pairs — as the width shrinks, the height grows to match. So you only need to check widths up to √n, and the rest come along automatically. If there's ever a moment where the width and height are equal, that number is a perfect square.
Prime numbers are special here. They only have 2 divisors (1 and themselves), so the only rectangle you can make is 1×n. Move the slider and watch the rectangle list suddenly get short near a prime number.