Advertisement
donnaken15

prime number calculator c++/holyc

Feb 24th, 2019
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. WINDOWS:
  2. #include <iostream>
  3.  
  4. bool isPrime;
  5.  
  6. unsigned long unsigned long a, b;
  7.  
  8. int main()
  9. {
  10.   for (a = 3; a < ULLONG_MAX; a += 2)
  11.   {
  12.     for (b = 3; b < a; b += 2)
  13.     {
  14.       if (a % b == 0)
  15.       {
  16.         isPrime = false;
  17.         break;
  18.       }
  19.       isPrime = true;
  20.     }
  21.     if (isPrime)
  22.       printf("%d,", a);
  23.   }
  24. }
  25.  
  26. TEMPLEOS:
  27. Bool isPrime;
  28. U64 i;
  29. U64 j;
  30. U0 main()
  31. {
  32.   for (i = 3; i < U64_MAX; i += 2)
  33.   {
  34.     for (j = 3; j < i; j += 2)
  35.     {
  36.       if (i % j == 0)
  37.       {
  38.         isPrime = 0;
  39.         break;
  40.       }
  41.       isPrime = 1;
  42.     }
  43.     if (isPrime == 1)
  44.     {
  45.       "%d\n",i;
  46.     }
  47.   }
  48. }
  49. main;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement