diff --git a/primtallYey/hei1 b/primtallYey/hei1 new file mode 100755 index 0000000..00b8c46 Binary files /dev/null and b/primtallYey/hei1 differ diff --git a/primtallYey/hei2 b/primtallYey/hei2 new file mode 100755 index 0000000..24f2c38 Binary files /dev/null and b/primtallYey/hei2 differ diff --git a/primtallYey/hei3 b/primtallYey/hei3 new file mode 100755 index 0000000..a8a5bd2 Binary files /dev/null and b/primtallYey/hei3 differ diff --git a/primtallYey/p.c b/primtallYey/p.c new file mode 100644 index 0000000..de767a8 --- /dev/null +++ b/primtallYey/p.c @@ -0,0 +1,35 @@ +#include +#include +#include + +bool checkPrime(int p, int *pptr){ + int sqrt_p = sqrt(p); + for(int i = 0; i < sqrt_p; i++){ + if(p % *(pptr+i) == 0){return false;} + } + return true; +} + +int main(){ + double max = pow(10,7); + int pi_max = (int)(ceil(1.1*(max/log(max)))); + int primes[pi_max]; + primes[0] = 2; + int *pptr = &primes[0]; + int count = 1; + + //calculate primes + for(int c = 3; c <= max; c+=2){ + if(checkPrime(c, pptr)){ + primes[count] = c; + count++; + } + } + + //print primes + printf("The set of all primes below %d is: ", (int)max); + for (int i = 0; i < count; i++){ + printf("%d ", primes[i]); + } + return 0; +} diff --git a/primtallYey/p.o b/primtallYey/p.o new file mode 100644 index 0000000..f93f203 Binary files /dev/null and b/primtallYey/p.o differ