
public int solution(int n) {
int answer = 0;
int x = 1;
if (3 <= n && n <= 1000000) {
while (n % x != 1) {
x++;
} answer = x;
}
return answer;
}
IntSummaryStatistics 객체는 최소값, 최대값, 합계, 평균 등 여러 통계 정보를 제공한다.
import java.util.Arrays;
import java.util.IntSummaryStatistics;
public static String solution(String s) {
IntSummaryStatistics stats = Arrays.stream(s.split(" "))
.mapToInt(Integer::parseInt)
.summaryStatistics();
return stats.getMin() + " " + stats.getMax();
}