素数判断函数有漏洞的,修改如下,供参考:
int prime(int x) { int k; for(k=2;k<x;k++) if(x%k==0) return 0; return (x != 1); }