Beispiel #1
0
        public void VerifySquareRootByBinarySearch(int n)
        {
            if (n < 0)
            {
                Assert.Throws <ArgumentException>(() => IntegerMath.SquareRootBinarySearch(n));
            }
            else
            {
                var approach1 = (int)Math.Sqrt(n);
                var approach2 = (int)Math.Floor(Math.Sqrt(n));
                var approach3 = IntegerMath.SquareRootBinarySearch(n);

                Assert.Equal(approach1, approach2);
                Assert.Equal(approach1, approach3);
            }
        }
Beispiel #2
0
 public void BinarySearchSquareRoot()
 {
     _ = IntegerMath.SquareRootBinarySearch(N);
 }