Click here to Skip to main content
12,897,483 members (52,267 online)
Click here to Skip to main content
Add your own
alternative version


6 bookmarked
Posted 4 Aug 2010

Using CheckedListBox in Multiplication

, 4 Aug 2010 CPOL
Rate this:
Please Sign up or sign in to vote.
Ancient Egyptian multiplication and Russian peasants multiplication


When you use your computer or your calculator to do difficult calculations, or when you see your child easily do the following multiplication...

x   43

...we have to remember the suffering of the ancient people throughout history to calculate the operations of arithmetic. However, they left us great works certifying that they were geniuses.
History tells us about two operations of multiplication, Ancient Egyptian multiplication and Russian peasants multiplication.

Ancient Egyptian Multiplication

Here is how 43 is multiplied by 68:

  1. Start with number 1 in the first column and keep doubling (the first column has powers of two), the largest power of two less than or equal to the first number(43).
  2. Start with the second number (68) in the second column, keep doubling the number in the second column.
  3. Subtract the largest power of two less than or equal to the first number(43),
    43 - 32 = 11,
    subtract the largest power of two less than or equal to the remainder(9),
    11 - 8 = 3
    3 - 2 = 1
    repeat until nothing remains,
    1 - 1 = 0
    Now you see that 43 = 32 + 8 + 2 + 1.
  4. To get the result, check the numbers in the second column corresponding to 32, 8, 2, 1 and add them.

Russian Peasants Multiplication

See how 43 is multiplied by 68:

  • Write each number at the head of a column.
  • Divide the number in the first column by 2, flooring the quotient (drop the remainder), until there is nothing left to divide.
  • Keep doubling the number in the second column, until you have doubled it as many times as you divided the number in the first column.
  • To get the result, add up all the numbers in the second column that are next to an odd number in the first column.


To test the previous operations of multiplication, begin a new project with one form, put the following controls on the form:

  • Two controls of TextBox: txtFirst and txtSecond to enter two numbers.
  • Two controls of CheckedListBox for Ancient Egyptian multiplication: lstEgyptian1 and lstEgyptian2.
  • Two controls of CheckedListBox for Russian peasants multiplication: lstRussian1 and lstRussian2.
  • Two controls of Label to print the result: EgyptianResult and RussianResult.
  • Three controls of Buttons: btnEgyptianCalc, btnRussianCalc to get the result and btnExit to exit the program.

About the Code

Fill the first list:

private void FillListEgyptian1()
   newVlue = 1;

    numFirst = Convert.ToInt32(txtFirst.Text);
    //add powers of two (less than numFirst) to 'lstEgyptian1'
    while (newVlue <= numFirst) 
        newVlue = 2 * newVlue; //the first column has powers of two
} int 

Fill the second list:

private void FillListEgyptian2()
    numSecond = Convert.ToInt32(txtSecond.Text);
    for(int i = 1; i < lstEgyptian1.Items.Count; i++)
        numSecond = numSecond * 2; //keep doubling the second number

Check numbers at first column:

private void CheckEgyptianNumbers()
    int newNumber = numFirst;
    int i = lstEgyptian1.Items.Count;

        int binNumber = (int)(lstEgyptian1.Items[i]);
        if(binNumber <= newNumber) //is power of 2 < newNumber?
            newNumber = newNumber - binNumber;
            lstEgyptian1.SetItemChecked(i, true); //check it
            lstEgyptian2.SetItemChecked(i, true); //check it
    while (i > 0);

Add numbers to get the result:

private void GetEgyptianMultiplication()
    long TheResult = 0;
    for(int i = 0; i < lstEgyptian2.Items.Count; i++)
        if(lstEgyptian2.GetItemChecked(i) == true)
            TheResult = TheResult + (int)(lstEgyptian2.Items[i]);
            EgyptianResult.Text = TheResult.ToString();

You can read the code of Russian peasants multiplication.

Final Words

We must not forget what knowledge the previous generations have given us.

Said Isaac Newton,

"I stand on the shoulders of my predecessors".

Thanks to Code Project and thanks to all.


  • 4th August, 2010: Initial post


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

No Biography provided

You may also be interested in...


Comments and Discussions

GeneralMy vote of 4 Pin
dbrenth10-Aug-10 3:12
memberdbrenth10-Aug-10 3:12 
GeneralMy vote of 5 Pin
cornelha4-Aug-10 23:00
membercornelha4-Aug-10 23:00 
GeneralMy vote of 1 Pin
AxelM4-Aug-10 20:35
memberAxelM4-Aug-10 20:35 
GeneralGood article.....but Pin
Shivprasad koirala4-Aug-10 16:38
mvpShivprasad koirala4-Aug-10 16:38 
GeneralRe: Good article.....but Pin
cornelha4-Aug-10 22:59
membercornelha4-Aug-10 22:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170424.1 | Last Updated 4 Aug 2010
Article Copyright 2010 by Mostafa Kaisoun
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid