Read about doing multiplication using Karatsuba method
(https://en.wikipedia.org/wiki/Karatsuba_algorithm ).
Write a C++ program which:
• Prompts user to enter two large integer numbers (x, y).
• Make a function called Karatsuba() which takes these two integers and returns the
multiplication result using Karatsuba algorithm.
o Your function should do parameter validation. Both numbers must be more
than 4 digits and less than 10 digits (don’t use strings). If parameters are not
valid then the function should return 0;
o The entered numbers could be negative or positive. For example: 820778 and
-58712979 where x is 6-digit positive number and y is 8-digit negative
number.
• You might need to make another helper function called getDigits() which will get an
integer as input and returns number of digits of that integer. getDigits() will help you
find the value of m and Bm.
• Finally, display result in the main function
Comments
Leave a comment