-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path009.cs
More file actions
38 lines (32 loc) · 926 Bytes
/
Copy path009.cs
File metadata and controls
38 lines (32 loc) · 926 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//Special Pythagorean triplet
//Problem 9
//A Pythagorean triplet is a set of three natural numbers, a < b < c, for which,
//a2 + b2 = c2
//For example, 32 + 42 = 9 + 16 = 25 = 52.
//There exists exactly one Pythagorean triplet for which a + b + c = 1000.
//Find the product abc.
namespace _009
{
class Program
{
static void Main(string[] args)
{
for (int x = 0; x < 1000; x++)
{
for (int y = 0; y < 1000; y++)
{
for (int z = 0; z < 1000; z++)
{
if ( (x*x)+y*y==z*z && (x + y + z) == 1000 && x< y && y<z)
Console.WriteLine("found: " + x + " " + y + " " + z);
}
}
}
}
}
}