Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CSCI 1170: Open Lab Assignment #4 Friday, 3/16 (turn in box closes Friday Program due: night) Purpose of this assignment: The purpose of this assignment

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
CSCI 1170: Open Lab Assignment #4 Friday, 3/16 (turn in box closes Friday Program due: night) Purpose of this assignment: The purpose of this assignment is to understand Repetition control. Background For this assignment, you will be implementing the so-called "Russian Peasant" or "Ancient Egyptian" method for multiplication. It looks a little odd, but just think of it as an algorithm, a recipe for doing multiplication in a way other than what you learned in grade school For a detailed description of how the algorithm works, please visit the links http://en.wikipedia.org/wiki/Ancient Egyptian multiplicatio The algorithm is as follows. If A and B are the 2 integers (only integers) to be multiplied, we repeatedly multiply A by 2 and divide B by 2, until B can't be divided any further, that is until its value becomes 0 (remember, this is integer division). During each step, whenever B is an odd number, we add the corresponding A value to the product we are generating. In the end, the sum of the A values that had corresponding odd B values is the product. Get it? Here's an example: If the two integers to be multiplied are 34 and 19, the operations would be: A B Comment 34 68 136 272 544 19 9 4 2 add A to the product, B is odd add A to the product, B is odd ignore this A value, B is even ignore this A value, B is even B is odd add A to the Sum up al the A values that had odd B values and you get 34 + 68 + 544 = 646 => Final Product Specifications

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

AutoCAD Database Connectivity

Authors: Scott McFarlane

1st Edition

0766816400, 978-0766816404

More Books

Students also viewed these Databases questions