Ejemplo n.º 1
0
        public static IEnumerable <Tuple <int, int, int> > PythagoreanTripletsPerimeter(int perimeter)
        {
            for (int i = 1; i < perimeter; i++)
            {
                for (int j = i + 1; j < perimeter; j++)
                {
                    for (int k = j + 1; k < perimeter; k++)
                    {
                        if (i + j + k == perimeter && ValueExtensions.IsPythagoreanTriplet(i, j, k))
                        {
                            yield return(Tuple.Create(i, j, k));
                        }
                    }
                }
            }

            yield break;
        }
Ejemplo n.º 2
0
        public static IEnumerable <Tuple <int, int, int> > PythagoreanTriplets(int maxValue)
        {
            for (int i = 1; i < maxValue; i++)
            {
                for (int j = i + 1; j < maxValue; j++)
                {
                    for (int k = j + 1; k < maxValue; k++)
                    {
                        if (ValueExtensions.IsPythagoreanTriplet(i, j, k))
                        {
                            yield return(Tuple.Create(i, j, k));

                            break;
                        }
                    }
                }
            }

            yield break;
        }