-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEulerFive.cs
35 lines (32 loc) · 1.08 KB
/
EulerFive.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
// Project Euler Problem #5
// Find the smallest number which divides evenly the numbers 1 through 20.
// BRUTE FORCE APPROACH
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ProjectEuler
{
class EulerFive
{
static ulong num = 100, answer;
static bool sol = false;
static void Main(string[] args)
{
while (!sol)
{
if (num % 1 == 0 && num % 2 == 0 && num % 3 == 0 && num % 4 == 0 && num % 5 == 0 && num % 6 == 0 && num % 7 == 0 && num % 8 == 0 && num % 9 == 0 && num % 10 == 0
&& num % 11 == 0 && num % 12 == 0 && num % 13 == 0 && num % 14 == 0 && num % 15 == 0 && num % 16 == 0 && num % 17 == 0 && num % 18 == 0 && num % 19 == 0 && num % 20 == 0)
{
answer = num;
sol = true;
break;
}
num++;
}
if (sol == true)
Console.Write("The answer is: " + answer);
Console.Read();
}
}
}