Problem 42636. Big Integer Multiplication
Implement big integer multiply.
Input:
A, B : N-by-M Matrix, each row represents a positive decimal integer.
Output:
C : N-by-P Matrix, each row represents the decimal integer A*B.
Example 1:
a = [1 2 3;0 5 6]; b = [5 6;9 0]; c = BigIntMult(a,b) c = 6 8 8 8 5 0 4 0
123*56=6888 (c(1,:)), 56*90=5040 (c(2,:))
Example 2 (singleton expansion):
a = [1 2 3;0 5 6]; b = [5 7]; c = BigIntMult(a,b) c = 7 0 1 1 3 1 9 2
123*57=7011 (c(1,:)), 56*57=3192 (c(2,:))
Note:
1.you don't need to remove the leading zeroes.
2.your score will depend on your solution performance.
Solution Stats
Problem Comments
-
6 Comments
Is the 123 in a(1,:) being multiplied by the 056 in a(2,:) or the 56 in b(1,:)?
The 56 in b(1,:).
The latter.
The 56 in b(1,:),Thank you for pointing out the confusion James.I'll edit it.
Note that in Test case #3, b is a row vector (1xm) as opposed to a matrix (nxm) as mentioned in the problem description.
Also, Test case #1, set for manually assigning score based on performance, is no longer valid and any solution submitted now on (even if correct) won't be accepted.
I even ran Tim's solution to verify that the problem was with the test case and not the solutions submitted.
Last accepted solution is J.R.! Menzinger's on 6 Aug 2021.
As Dyuman pointed out, tests 1 and 4 are broken. The code to be read in test 1 doesn't seem to exist any more. Would it be possible to comment out test 1 and the last line of test 4?
Solution Comments
Show commentsProblem Recent Solvers7
Suggested Problems
-
Program an exclusive OR operation with logical operators
713 Solvers
-
Numbers with prime factors 2, 3 and 5.
469 Solvers
-
Getting the indices from a matrix
635 Solvers
-
106 Solvers
-
6980 Solvers
More from this Author8
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!