Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Draw two columns on a piece of paper. Write the 29 at the top of one column and 13 at the top of the other.

image text in transcribed

Draw two columns on a piece of paper. Write the 29 at the top of one column and 13 at the top of the other. Now, half the entry in the first column, and write it down on the next row, discarding any remainder. Then double the entry in the second column and write that down too. Repeat the previous step until you get a 1 in the left column. Strike through all the rows where the element in the left column is even. Add up the all those elements in the right column that remain. The result of that sum is the product of 29 and 13: 13 + 52 + 104 + 208 = 377 Write a Haskell function called myMult that uses this approach to compute the product of its two inputs. It should do this by building a list of pairs (for each row) through a recursive process, and summing up the appropriate entries. myMult :: (Integral a) => a -> a -> a Draw two columns on a piece of paper. Write the 29 at the top of one column and 13 at the top of the other. Now, half the entry in the first column, and write it down on the next row, discarding any remainder. Then double the entry in the second column and write that down too. Repeat the previous step until you get a 1 in the left column. Strike through all the rows where the element in the left column is even. Add up the all those elements in the right column that remain. The result of that sum is the product of 29 and 13: 13 + 52 + 104 + 208 = 377 Write a Haskell function called myMult that uses this approach to compute the product of its two inputs. It should do this by building a list of pairs (for each row) through a recursive process, and summing up the appropriate entries. myMult :: (Integral a) => a -> a -> a

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals Design

Authors: Marion Donnie Dutton Don F. Seaman

14th Edition Globel Edition

1292107634, 978-1292107639

More Books

Students also viewed these Databases questions