Guest User

Untitled

a guest
Jan 19th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.65 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <windows.h>
  4. /*2.2400 sek */
  5. int main () {
  6.     unsigned long long i=0;
  7.     unsigned long long j=0;
  8.     int primecount=1;
  9.     int markercount=0;
  10.     DWORD dwStartTime = GetTickCount();
  11.     DWORD dwElapsed;
  12.  
  13.     for (i=3;i>0;i+=2) {
  14.         if (primecount == 10001) break;
  15.         for (j=2;j<=i;j++) {
  16.             if (i%j==0 && i!=j) break;
  17.             if (j > i/4) {j=i;primecount++;}
  18.         }
  19.     }
  20.  
  21.     printf("Primecount is %d. And the prime number is: %d\n", primecount, i-2);
  22.     dwElapsed = GetTickCount() - dwStartTime;
  23.     printf("It took %d.%3d seconds to complete\n", dwElapsed/1000, dwElapsed - dwElapsed/1000);
  24.     system("pause");
  25.     return 0;
  26. }
Add Comment
Please, Sign In to add comment