Advertisement
Guest User

Untitled

a guest
Nov 30th, 2014
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. //FIND THE 100001st PRIME NUMBER.
  2. static void Main(string[] args)
  3. {
  4. bool isPrime = true;
  5. int count = 0;
  6. int i;
  7.  
  8. for (i = 1; i <= 100000; i++)
  9. {
  10. isPrime = true;
  11. for (int j = 2; j < i; j++)
  12. {
  13. if (i % j == 0)
  14. {
  15. isPrime = false;
  16. break;
  17. }
  18. else { isPrime = true; }
  19. }
  20. if (isPrime)
  21. {
  22. count++;
  23. }
  24. if (count == 10001)
  25. {
  26. break;
  27. }
  28. }
  29. Console.WriteLine(i);
  30. Console.ReadLine();
  31. }
  32. //Always getting output as "100001"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement