import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Sieve_of_Eratosthenes {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
int N = Integer.parseInt(st.nextToken());
int K = Integer.parseInt(st.nextToken());
int[] list = new int[N+1];
for (int i = 2; i <= N; i++) {
list[i] = i;
}
int cnt = 0;
for(int i = 2; i<=N; i++){
int count = 0;
for(int j = 2; j<i; j++){
if(i/j==0){
count++;
break;
}
}
if(count==0){
for(int k = 1; i*k <= N;k++){
if(list[i*k]!=0){
cnt++;
if(cnt == K){
System.out.println(list[i*k]);
return;
}
list[i*k] = 0;
}
}
}
}
}
}
아니 나 이거 틀리게 제출했는데 맞다고 나왔다. 하지만 귀찮으니 이의제기는 안해야지.
그리고 2도 소수다. 초등학생도 아는거라고 하지만, 나도 초등학생때는 알았다. 까먹지말자
소수문제 나올때 한번 생각해 볼 것중에 어떤수가 소수인지 확인할때 2부터 그 수의 제곱근까지만 확인하면 소수판별이 가능하다. 개꿀팁이니 까먹지 말자
ex) 25는 5까지만, 41은 6까지만 확인해보면 소수인지 판별가능