[Codility Lessons] MinPerimeterRectangle(28/n)
[Lesson10] Prime and composite numbers
MinPerimeterRectangle
import java.util.*;
class Solution {
public int solution(int N) {
int i = 1;
int min = Integer.MAX_VALUE;
while(i*i <= N){
if(N%i == 0){
min = Math.min(min, 2*((N/i)+i));
}
i++;
}
return min;
}
}