/*求2-n之间的所有素数*/ #include <stdio.h> #include <math.h> void main() { int i,j,n,m; printf ( "请输入一个大于2的整数:\n" ); scanf ( "%d",&n ); for ( j=2; j<=n; j++ ) { m= ( int ) sqrt ( ( double ) j ); for ( i=2; i<=m; i++ ) { if ( j%i==0 ) { break; } } if ( i>m ) { printf ( "%d是素数\n",j ); } } }