Example #1
0
        public void Verify_WithSingleDigitNumbers()
        {
            var sum = "10";

            Assert.AreEqual(sum, KaratsubaMultiplication.Add("5", "5"));

            sum = "0";
            Assert.AreEqual(sum, KaratsubaMultiplication.Add("0", "0"));

            sum = "1";
            Assert.AreEqual(sum, KaratsubaMultiplication.Add("0", "1"));
        }
Example #2
0
        public void Verify_WithDoubleDigitNumbers()
        {
            var sum = "30";

            Assert.AreEqual(sum, KaratsubaMultiplication.Add("15", "15"));

            sum = "29";
            Assert.AreEqual(sum, KaratsubaMultiplication.Add("10", "19"));

            sum = "69";
            Assert.AreEqual(sum, KaratsubaMultiplication.Add("29", "40"));
        }
Example #3
0
 static void Main(string[] args)
 {
     Console.WriteLine(KaratsubaMultiplication.Multiply("123456789", "123456789").TrimStart('0'));
     Console.WriteLine(123456789L * 123456789);
 }