Question: The Russian peasant algorithm for multiplication uses the decrease by a constant factor approach to developing an algorithm. For this assignment, create a Java class
The Russian peasant algorithm for multiplication uses the decrease by a constant factor approach to developing an algorithm.
For this assignment, create a Java class that has three fields, two factors and one product (all ints).
Then write a method that implements this algorithm (see text section 4.4) using a loop. Then write a second method that implements this algorithm using recursion. Write any other methods needed to retrieve the needed values.
Write a Driver class with main( ) that allows the user to enter two integer factors and call one or both of the methods to obtain the product. Print the product to the screen.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
