Kumar-laxmi / Algorithms

A Repository for algorithms in C, C++, Python and Java
Apache License 2.0
325 stars 367 forks source link

Adding of Russian Peasant Algorithm #1746

Closed Aarsh30 closed 1 year ago

Aarsh30 commented 1 year ago

The "Russian peasant algorithm" is a traditional method for performing multiplication that dates back to ancient times. It is also known as the "Russian peasant multiplication" or the "Egyptian multiplication" algorithm.

🛠️ Issue (1519)

1519

Here's how it works:

Start with two numbers, the multiplicand (the number you want to multiply) and the multiplier (the number by which you want to multiply).

Create two columns. In the left column, write down the multiplicand. In the right column, write down the multiplier.

Divide the number in the left column by 2 (ignore any remainder), and double the number in the right column. Continue this process until the number in the left column becomes 1.

Cross out any row where the number in the left column is even.

Add up all the numbers in the right column that are not crossed out. The sum of these numbers is the result of the multiplication.

Issue no #1519

✔️ Check List (Check all the applicable boxes)

📄 Note to reviewers

📷 Screenshots

c c++ java python

github-actions[bot] commented 1 year ago

Thanks for your contribution we will soon check your PR @Aarsh30 :)