diff options
| author | Reiner Herrmann <reiner@reiner-h.de> | 2014-08-31 20:21:45 +0200 |
|---|---|---|
| committer | Reiner Herrmann <reiner@reiner-h.de> | 2014-08-31 20:35:09 +0200 |
| commit | 95341b61b030c9e1290f3b326cb7ec584f543aea (patch) | |
| tree | 852386fa04d32eb859bca11c0eff7b5ef9e50f00 /187.c | |
| parent | 571164d977f91925c4c76a292f74f5f93d09ae23 (diff) | |
Diffstat (limited to '187.c')
| -rw-r--r-- | 187.c | 28 |
1 files changed, 28 insertions, 0 deletions
@@ -0,0 +1,28 @@ +#include "common.h" +#include <stdlib.h> +#include <string.h> + +const unsigned long limit = 100000000; + +int main(void) +{ + unsigned long* p = primes(limit/2); // sqrt(limit) + unsigned long pcount = p[0]; + unsigned long rcount = 0; + unsigned long i1, i2; + + for(i1=1; i1<=pcount; i1++) + for(i2=i1; i2<=pcount; i2++) + { + unsigned long long result = (unsigned long long) p[i1] * p[i2]; + if(result >= limit) + break; + rcount++; + } + + printf("%li\n", rcount); + + free(p); + return 0; +} + |
