Solution to Codility Min-Perimeter-Rectangle problem.
Given a rectangle area \(A\), find the smallest possible perimeter for a rectangle with integer sidelengths and area \(A\).
We just iterate through all the possible divisors, and update the mininum perimeter.
public int solution(int N) {
int minPer = Integer.MAX_VALUE;
for(int i = 1; i*i <= N; i++){
if(N % i == 0){
minPer = Math.min(minPer, 2*(N/i + i));
}
}
return minPer;
}