I need to get two factors ( x, y ) of a given number ( n ) such that:
- x * y <= n
- x * y should be as close to n as possible
- x and y should be as close to each other as possible.
Examples:
- n = 16 => x = 4, y = 4
- n = 17 => x = 4, y = 4
- n = 18 => x = 6, y = 3
- n = 20 => x = 5, y = 4
Any language will do but preferably php.
EDIT -- CLARIFICATION
I want to create a rectangle, x units wide * y units tall such that its area is as close to n as possible. x and y must be integers. If n is a prime number then factors of n - 1 are acceptable.