Codility - MinPerimeterRectangle

RESULT

import java.util.*;

class Solution {
    public int solution(int N) {
        int root = (int) Math.sqrt(N);
        for (int i=root; i>0; i--) {
            if (N % i == 0) {
                return ((i + (N / i)) * 2);
            }    
        }
        
        return -1;
    }
}