github.com/stealthrocket/wzprof@v0.2.1-0.20230830205924-5fa86be5e5b3/testdata/c/crunch_numbers.c (about)

     1  #include <stdio.h>
     2  
     3  int isPrime(int n) {
     4    if (n == 2 || n == 3) {
     5      return 1;
     6    }
     7  
     8    if (n <= 1 || (n%2) == 0 || (n%3) == 0) {
     9      return 0;
    10    }
    11  
    12    for (int i = 5; (i * i) <= n; i += 6) {
    13      if ((n%i) == 0 || (n%(i+2)) == 0) {
    14        return 0;
    15      }
    16    }
    17  
    18    return 1;
    19  }
    20  
    21  int main() {
    22    int rc = 0;
    23    for (int i = 0; 1; i++) {
    24      if (isPrime(i)) {
    25        rc = i;
    26        // printf("%d\n", i);
    27      }
    28    }
    29    return rc;
    30  }