프로그래머스 - 합성수 찾기

차관호·2023년 3월 13일
0

문제링크 - 프로그래머스 - 합성수 찾기

class Solution {
    public int solution(int n) {
        int count;
        int re=0;
        for(int i =1; i<=n;i++){
            count = 0;
            for(int j=1;j<=i;j++){
                if(i%j==0){
                    count++;

                    if(count==3){
                        re++;
                        break;
                    }
                }
            }

        }
        return re;
    }
}
profile
안녕하세요 :-)

0개의 댓글