1: #include<stdio.h>
2: #include<conio.h>
3: #include<math.h>
4: void main()
5: {
6: int n,k,remainder;
7: int prime;
8: for(n=2;n<=100;n++)
9: {
10: prime=1;
11: k=2;
12: while(k<=sqrt(n))
13: {
14: remainder=n%k;
15: if(remainder==0)
16: {
17: prime=0;
18: break;
19: }
20: else
21: k++;
22: }
23: if(prime==1)
24: printf("%d is the prime num\n",n);
25: }
26: getch();
27: }
No comments:
Post a Comment