i have a problem in square root

example :

sqrt of 180 =1 √180, 2 √45, 3 √20 or 6 √5.

but i want to calculate the maximum factor next to root that i want to calculate

6 √5. becz 6 > 3 > 2 > 1

i started with prime factors

2,3,5

and factorising 180

=

2

3

3

2

5

then 180=180/5=36

if 36 has a square root

so it is the biggest factor

but i failed in some examples like

2197

the result should be 13 * root 13

but with my method it will be wrong

can anyone help me