首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

(Problem 七)10001st prime

2013-11-23 
(Problem 7)10001st prime#include stdio.h#include string.h#include ctype.h#include math.hint

(Problem 7)10001st prime
#include <stdio.h>#include <string.h>#include <ctype.h>#include <math.h> int prim(int n){ int i; for(i=2; i*i<=n; i++) { if(n%i==0) return 0; } return 1;} void solve(int n){ int i=2; int count=0; while(1) { if(prim(i)) { count++; if(count==n) break; } i++; } printf("%d\n",i);} int main(){ int n=10001; solve(n); return 0;}

?

Answer:104743

热点排行