Multiply Without Using *

I came out with this C# algorithm to solve this problem, I did a research and found a better solution named Russian Peasant please research for that, I this code I will do by sum number a  and accumulate the sum b times.

        /// <summary>
        /// Multiplies withou using Multiply
        /// </summary>
        /// <param name="a">first number</param>
        /// <param name="b">second number</param>
        /// <returns>multiply</returns>
        private static int Multiply(int a, int b)
            int total = 0; // sum
            for (int i = 1; i <= b; i++)
                total += a; // sum number a as many timeas as b
            return total;

As I said is not the most efficient maybe research on what I wold you.


Leave a Reply

Your email address will not be published. Required fields are marked *