본문 바로가기
Beakjoon&프로그래머스/Java

[프로그래머스/Java] 약수 구하기

by 현장 2025. 2. 18.

-Code

import java.util.stream.IntStream;

class Solution {
    public int[] solution(int n) {
        return IntStream.rangeClosed(1, n).filter(el -> n % el == 0).toArray();
    }
}