/ test_src / d / first1000primes / 001 / primes.d
primes.d
 1  import std.stdio;
 2  
 3  bool isPrime(int n) {
 4      if (n < 2) return false;
 5      if (n == 2) return true;
 6      if (n % 2 == 0) return false;
 7      for (int i = 3; i * i <= n; i += 2) {
 8          if (n % i == 0) return false;
 9      }
10      return true;
11  }
12  
13  void main() {
14      int count = 0;
15      int num = 2;
16      int lastPrime = 0;
17      
18      while (count < 1000) {
19          if (isPrime(num)) {
20              lastPrime = num;
21              count++;
22          }
23          num++;
24      }
25      
26      writeln(lastPrime);
27  }