-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path007.cs
More file actions
47 lines (36 loc) · 936 Bytes
/
Copy path007.cs
File metadata and controls
47 lines (36 loc) · 936 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//10001st prime
//Problem 7
//By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.
//What is the 10 001st prime number?
namespace _007
{
class Program
{
static List<int> primes = new List<int>();
static void Main(string[] args)
{
int x = 2;
while(primes.Count != 10001)
{
if (isPrime(x))
primes.Add(x);
x++;
}
Console.WriteLine(primes[10000]);
}
static bool isPrime(int number)
{
for (int x = 0; x < primes.Count; x++)
{
if (number % primes[x] == 0)
return false;
}
return true;
}
}
}