uploaded at 2022. 12. 16. 오후 8:35:35

This commit is contained in:
rl544
2022-12-16 20:35:36 +09:00
parent 607c1192f3
commit e1ddeb4fd4
+18
View File
@@ -0,0 +1,18 @@
// [문제 링크]: https://school.programmers.co.kr/learn/courses/30/lessons/12921
class Solution {
public int solution(int n) {
int answer = 0;
for(int a = 2; a<=n; a++){
int t = 0;
for(int b=2; b<=Math.sqrt(a); b++){
if(a%b==0) {
t = 1;
break;
}
}
if(t == 0) answer+= 1;
}
return answer;
}
}