这是indexloc提供的服务,不要输入任何密码
Skip to content

hisuwh/Kata-RussianPeasantMulti

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Kata Russian Peasant Multication

It is said that Russian peasants multiply using a most curious method, They start by writing the two numbers to be multiplied at the head of two columns. Then they repeatedly divide the number in the left column by two (dropping any remainder) and double the number in the right column, writing the two new numbers immediately below their predecessors, until the number in the left column is one. Then they cross out all rows where the number in the left column is even, and add the remaining numbers in the right column, which is the desired product. For instance, the product eighteen times twenty-three is found like this.

http://img.thedailywtf.com/images/200907/RussianPeasant.gif

Your challenge: write a function that multiplies two numbers using the Russian peasant algorithm. There is no language restriction, though anything on the esoteric language list will probably be ignored. Spoiler alert: the solution(s) will undoubtedly appear in the comments.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%