Closest to a square

05AB1E, 3 bytes

Given an input \$ c \$, it outputs \$ a \$ and \$ b \$ as a list in increasing order. If \$ c \$ is a square, it outputs a single integer (which according to the OP is allowed).

ÑÅs

Try it online!

Explanation

Ñ     # All divisors
Ås    # Middle elements

JavaScript (ES7), 35 bytes

f=(n,d=n**.5)=>n%d?f(n,-~d):[d,n/d]

Try it online!

How?

If \$n\$ is a square, \$d=\sqrt{n}\$ is an integer which obviously divides \$n\$, so we immediately have an answer. Otherwise, the first -~d will act as \$\lceil{d}\rceil\$ and the next ones as \$d+1\$. Either way, we stop as soon as \$n\equiv 0\pmod{d}\$ which in the worst case (i.e. if \$n\$ is prime) happens when \$d=n\$.


Python 2, 45 bytes

i=n=input()
while(i*i>n)+n%i:i-=1
print n/i,i

Try it online!