C語言源碼: [cpp] #include<stdio.h> int s[10005],top; void pri() { int i,num; s[top++]=2; num=3; while(top<10000) { for(i=0;i<top;i++) if(num/s[i]*s[i]==num) break; if(i==top) s[top++]=num; num++; } } int main() { int k; pri(); while(scanf("%d",&k)!=EOF) printf("%d\n",s[k-1]); }