{"id":6640,"date":"2024-11-01T00:01:33","date_gmt":"2024-11-01T07:01:33","guid":{"rendered":"https:\/\/c-for-dummies.com\/blog\/?p=6640"},"modified":"2024-11-09T10:59:54","modified_gmt":"2024-11-09T18:59:54","slug":"ethiopian-multiplication","status":"publish","type":"post","link":"https:\/\/c-for-dummies.com\/blog\/?p=6640","title":{"rendered":"Ethiopian Multiplication"},"content":{"rendered":"<h2>Difficulty: &#9733; &#9733; &#9734; &#9734;<\/h2>\n<p>I remember memorizing the &#8220;times tables,&#8221; which is how most American kids learn to multiply. Committing single digit multiplication values to memory helps perform multiplication and division problems, but it&#8217;s not the only way to calculate the result.<br \/>\n<!--more--><br \/>\nFor example, Ethiopian Multiplication involves doubling, halving, and adding values to multiply. As an example, consider the calculation 18 &times; 44.<\/p>\n<p>For Ethiopian Multiplication you create a column below each value. The first column you halve the numbers. The second column you double them:<\/p>\n<p><code>18&nbsp;&nbsp;&nbsp;44<br \/>\n&nbsp;9&nbsp;&nbsp;&nbsp;88<br \/>\n&nbsp;4&nbsp;&nbsp;176<br \/>\n&nbsp;2&nbsp;&nbsp;352<br \/>\n&nbsp;1&nbsp;&nbsp;704<\/code><\/p>\n<p>Eighteen is even, so it divides evenly. When the value is odd, round it down to the next even number and then cut in half: 9 rounds down to 8, so the next value is 4, as shown above.<\/p>\n<p>The second step is to remove values from the second column where the value in the first column is even:<\/p>\n<p><code>18&nbsp;&nbsp;&nbsp;--<br \/>\n&nbsp;9&nbsp;&nbsp;&nbsp;88<br \/>\n&nbsp;4&nbsp;&nbsp;---<br \/>\n&nbsp;2&nbsp;&nbsp;---<br \/>\n&nbsp;1&nbsp;&nbsp;704<\/code><\/p>\n<p>The final step is to tally the values in the second column: 88 + 704 = 792, which is the result of 18 &times; 44.<\/p>\n<p>Your task for this month&#8217;s Exercise is to code Ethiopian Multiplication in C: Prompt the user for two integer values. Output the result using traditional math (the <code>*<\/code> operator) and then use the techniques for Ethiopian Multiplication to calculate the result. Output the total.<\/p>\n<p>Here is a sample run from my solution:<\/p>\n<p><code>First value: 18<br \/>\nSecond value: 44<br \/>\nTraditional: 18 * 44 = 792<br \/>\n&nbsp;&nbsp;Ethiopian: 18 * 44 = 792<\/code><\/p>\n<p>Please try this Exercise on your own before you peek at <a href=\"https:\/\/c-for-dummies.com\/blog\/?p=6650\">my solution<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Code this method for multiplying values which uses only doubling, halving, and addition. <a href=\"https:\/\/c-for-dummies.com\/blog\/?p=6640\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-6640","post","type-post","status-publish","format-standard","hentry","category-exercise"],"_links":{"self":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/6640","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6640"}],"version-history":[{"count":11,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/6640\/revisions"}],"predecessor-version":[{"id":6682,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/6640\/revisions\/6682"}],"wp:attachment":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6640"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6640"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6640"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}