-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEulerTwelve.cs
46 lines (38 loc) · 913 Bytes
/
EulerTwelve.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
45
46
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;
namespace ProjectEulerTwelve
{
class EulerTwelve
{
static int number = 0, i = 1;
private static int FindNumber(int number)
{
int divisors = 0;
for (int i = 1; i <= Math.Sqrt(number); i++)
{
if (number % i == 0)
{
divisors += 2;
}
}
if (Math.Pow(Math.Sqrt(number), 2) == number)
{
divisors--;
}
return divisors;
}
public static void Main()
{
while (FindNumber(number) < 500)
{
number += i;
i++;
}
Console.Write(number);
Console.Read();
}
}
}