-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
73 lines (69 loc) · 3.47 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
namespace EulerBricks
{
internal class EulerBricks
{
public static void Main()
{
const ulong max = 1000;
ulong
n = 0, i = 0,
a_min = 1, b_min = 1, c_min = 1,
a_max = max, b_max = max, c_max = max;
double d, e, f, g;
Console.WriteLine(value: "EulerBricks");
Console.Write(value: "Input the length of the run (default=1000, hit ENTER): ");
#pragma warning disable CS8600 // Converting null literal or possible null value to non-nullable type
string length = Console.ReadLine();
#pragma warning restore CS8600 // Converting null literal or possible null value to non-nullable type
if (ulong.TryParse(s: length, result: out a_max))
{
b_max = c_max = a_max;
}
else
{
Console.WriteLine(value: "Default value loaded!");
a_max = b_max = c_max = max;
}
for (ulong a = a_min; a < a_max; a++)
{
for (ulong b = b_min; b < b_max; b++)
{
for (ulong c = c_min; c < c_max; c++)
{
d = Math.Sqrt(d: Math.Pow(x: a, y: 2) + Math.Pow(x: b, y: 2));
if ((d % 1) == 0)
{
e = Math.Sqrt(d: Math.Pow(x: a, y: 2) + Math.Pow(x: c, y: 2));
if ((e % 1) == 0)
{
f = Math.Sqrt(d: Math.Pow(x: b, y: 2) + Math.Pow(x: c, y: 2));
if ((f % 1) == 0)
{
n++;
if (a <= b && a <= c && b <= c)
{
i++;
Console.WriteLine(value: $"{n}|{i} = {{a: {a}, b: {b}, c: {c}}}{{d: {Math.Round(a: (double)d)}, e: {Math.Round(a: (double)e)}, f: {Math.Round(a: (double)f)}}}");
}
else
{
Console.ForegroundColor = ConsoleColor.DarkGray;
Console.WriteLine(value: $"{n}|{i} = {{a: {a}, b: {b}, c: {c}}}{{d: {Math.Round(a: (double)d)}, e: {Math.Round(a: (double)e)}, f: {Math.Round(a: (double)f)}}}");
Console.ForegroundColor = ConsoleColor.White;
}
g = Math.Sqrt(d: Math.Pow(x: a, y: 2) + Math.Pow(x: b, y: 2) + Math.Pow(x: c, y: 2));
if ((g % 1) == 0)
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine(value: $"{n}|{i} = {{a: {a}, b: {b}, c: {c}}}{{d: {Math.Round(a: (double)d)}, e: {Math.Round(a: (double)e)}, f: {Math.Round(a: (double)f)}}}{{g: {Math.Round(a: (double)g)}");
Console.ForegroundColor = ConsoleColor.White;
}
}
}
}
}
}
}
}
}
}