-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathProgram.cs
44 lines (37 loc) · 1.02 KB
/
Program.cs
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
using System;
namespace _007
{
class Program
{
static bool IsPrime(int num)
{
if (num == 0 || num == 1)
return false;
for (int i = 2; i * i <= num; i++)
if (num % i == 0)
return false;
return true;
}
static int GetAnswer(int num)
{
int count = 0;
for (int i = 0;; i++)
if(IsPrime(i))
{
count++;
if (count == num)
return i;
}
}
static void Main(string[] args)
{
Console.BackgroundColor = ConsoleColor.White;
Console.ForegroundColor = ConsoleColor.Black;
Console.Clear();
Console.WriteLine("Project Euler. Verloka Vadim, 2019");
Console.WriteLine(new string('-', 50));
Console.WriteLine($"Answer: {GetAnswer(10001)}");
Console.Read();
}
}
}