document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. /*Name: Muhammad Azri bin Jasni @ Abdul Rani
  2. **http://projecteuler.net/problem=7
  3. By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.
  4.  
  5. What is the 10 001st prime number?*/
  6. /*
  7. http://fahad-cprogramming.blogspot.com/2012/01/find-prime-number-in-c.html
  8. if count == max, break
  9.  
  10. if  prime count++, num++
  11. */
  12. #include <iostream>
  13. using namespace std;
  14. bool isPrime(long long);
  15. int main()
  16. {
  17.     long long max=0, num, count;
  18.     cout << "Max?:" ;
  19.     cin >> max;
  20.     for (num=2, count=0; count<max; num++)
  21.     {
  22.         if (isPrime(num))
  23.         {
  24.             cout << num << " ";
  25.             count++;
  26.         }
  27.     }
  28.     cout << endl;
  29.     num--;
  30.     cout << "Num:" << num;
  31.     return 0;
  32. }
  33. bool isPrime(long long number)
  34. {
  35.      int count=0;
  36.      for (int a=1;a<=number;a++)
  37.      {
  38.          if (number%a==0)
  39.          {
  40.             count++;
  41.          }
  42.      }
  43.      if (count==2)
  44.      {
  45.         return true;
  46.      }
  47.      else
  48.      {
  49.          return false;
  50.      }
  51. }
');