[ create a new paste ] login | about

Link: http://codepad.org/EvKjMd36    [ raw code | output | fork ]

C, pasted on Jun 10:
#include <stdio.h>

int main()
{
  int i, j, n;
//  printf("number:");scanf("%d",&n);
  n = 50;
  if (n > 1) printf("2 ");
  for (i = 3; i <= n; i += 2) {
    int f = 1;
    for (j = 3; j * j < i+1; j += 2) {
      if ((i % j) == 0) {
        f = 0;
        break;
      }
    }
    if (f == 1)
      printf("%d ", i);
  }
  printf("\n");
  return 0;
}


Output:
1
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 


Create a new paste based on this one


Comments: