C# Min Perimeter Rectangle
static long MinPerimeterRectangle(long n)
{
    long i = 1;
    long min = long.MaxValue;

    while (i * i < n)
    {
        if (n % i == 0)
        {
            min = Math.Min(min, 2 * (i + n / i));
        }
        i++;
    }

    return min;
}

This searches factor pairs up to the square root and picks the pair with the smallest perimeter.