uploaded at 2022. 12. 16. 오후 8:35:35
This commit is contained in:
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user