daily pastebin goal
52%
SHARE
TWEET

prime number calculator c++/holyc

donnaken15 Feb 24th, 2019 (edited) 100 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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;
RAW Paste Data
Forex
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top