Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //FIND THE 100001st PRIME NUMBER.
- static void Main(string[] args)
- {
- bool isPrime = true;
- int count = 0;
- int i;
- for (i = 1; i <= 100000; i++)
- {
- isPrime = true;
- for (int j = 2; j < i; j++)
- {
- if (i % j == 0)
- {
- isPrime = false;
- break;
- }
- else { isPrime = true; }
- }
- if (isPrime)
- {
- count++;
- }
- if (count == 10001)
- {
- break;
- }
- }
- Console.WriteLine(i);
- Console.ReadLine();
- }
- //Always getting output as "100001"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement