I wrote this program to help me find all the prime numbers from 2 to i. The results are good, but I feel that something goes wrong in the program. Could you help me? Is everything OK with that piece of code:
Code:#include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { int i, j, k, n; printf("Give me the top number: \n"); scanf("%d", &i); for (j=2;j<i;j++){ for (k=2;k<i;k++) { n=j%k; if (n==0) break; }if (j==k) printf("%d:%d \n",j,k);} system("PAUSE"); return 0; }