예제 #1
0
 public long GetProductWhereSum(int sum)
 {
     for (long c = sum / 2; c >= sum / 3; c--)
     {
         for (long b = (sum - c); b > (sum - c) / 2; b--)
         {
             long a = sum - c - b;
             if (Pythagorea.isPythagorea(a, b, c))
             {
                 return(a * b * c);
             }
         }
     }
     throw new Exception("NO product found");
 }
예제 #2
0
 public void Test_GetNumberOfIntegerRightTriangles(int len, int expected)
 {
     /* The number 145 is well known for the property that the sum of the factorial of its digits is equal to 145: */
     Assert.Equal(expected, Pythagorea.GetNumberOfIntegerRightTriangles(len));
 }