Question: I need to derive a Width and Height given an area size in C#.
The Width and height need to be integer that are closest as possible to a square.
For example - Area = 100 --> Width = 10, Height = 10
Area = 162 --> Area = 162 --> Width = 18, Height = 9.

How can I do it?

Answer: 
Give this code snippet the area as an `int` and it computes the width and height as integers such that width \* height == area, and it as close to square as possible. 

```
int width;
for (width = (int)Math.Ceiling(Math.Sqrt(area)); width > 1; --width) {
   if (area % width == 0) break;
}
int height = area / width;

```

Note: I'm not a C# programmer. This is optimal in the sense that it satisfies the requirements optimally, but it is not the best in terms of runtime. This solution is O(sqrt(area)), which is not great since area can be in the order of 2^n for n bits in an int. You can look into [Integer Factorization](http://en.wikipedia.org/wiki/Integer_factorization) for more sophisticated methods to computing width if this is too expensive.
Here is a general answer which works for large numbers, in Python3.
It should be trivial enough to convert to C#, though you may have to write your own "prime factors" function.

```
from sympy.ntheory import primefactors

def int_root(n: int) -> tuple:
    root_n = math.sqrt(n)
    if 0 == n % root_n:
        a = int(root_n)
        return a, n // a
    pfs = primefactors(n)
    candidates = {1}
    for pf in pfs:
        for fi in range(math.ceil(math.log(root_n, pf))):
            candidates = candidates | {pf * c for c in candidates if pf * c < root_n}
    candidates = {c for c in candidates if n / c == n // c}
    a = max(candidates)
    return int(a), int(n / a)

```