[ create a new paste ] login | about

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

C, pasted on Dec 24:
#include <stdio.h>

#define START 20000
#define END   40000

int isPrime(int n)
{
  int i;
  for (i = 2; i < n / 2; i++) {
    if (n % i == 0)
      return 0;
  }
  return 1;
}

#define N 2
int is99(int n)
{
  int m;
  m = 0;
  while (n > 0) {
    if (n % 10 == 9)
      m++;
    n = n / 10;
  }
  if (m == N)
    return 1;
  return 0;
}

int main()
{
  int i;
  for (i = START; i <= END; i++) {
    if (!isPrime(i))
      continue;
    if (!is99(i))
      continue;
    printf("%d\n", i);
  }
  return 0;
}
/* end */


Output:
20399
20599
20899
20929
20939
20959
21499
21599
21799
21929
21991
21997
22699
22993
23099
23399
23599
23899
23909
23929
23993
24499
24799
24919
24979
24989
25799
25919
25939
25969
25997
26099
26399
26699
26959
26993
27299
27799
27919
27997
28099
28499
28909
28949
28979
29009
29059
29129
29179
29191
29209
29269
29297
29339
29389
29429
29569
29629
29669
29759
29789
29819
29879
29917
29921
29927
29947
29983
30949
31699
31799
31991
32099
32299
32909
32939
32969
32993
33199
33599
33997
34499
34919
34939
34949
35099
35899
35969
35993
36299
36599
36899
36919
36929
36979
36997
37199
37699
37799
37991
37993
37997
38299
38699
38959
38993
39019
39079
39089
39097
39119
39139
39191
39209
39229
39239
39293
39359
39397
39409
39419
39439
39509
39569
39619
39659
39679
39709
39719
39749
39769
39779
39791
39829
39839
39869
39901
39937
39953
39971
39983


Create a new paste based on this one


Comments: