import
java.util.stream.Stream;
public class
MinimumRectanglePerimeter {
public static void main(String[] args) {
System.out.println(perimeter(30));
}
public static int perimeter(int area) {
return Stream.iterate((int) Math.sqrt(area), n -> n - 1).filter(n -> area % n == 0).map(n -> 2 * (n + area / n)).findFirst().get();
}
}
No comments:
Post a Comment