Algebra
Mathematics
Algorithms
Logic
Write your algorithm, which can multiply without shifts :)
I.e, when multiplying the numbers 123 and 456 you should get an array of [4, 13, 28, 27, 18].
More details:
1 2 3
4 5 6
---------
6 12 18 #(6 x 1, 6 x 2, 6 x 3)
5 10 15 #(5 x 1, 5 x 2, 5 x 3)
4 8 12 #(4 x 1, 4 x 2, 4 x 3)
4 13 28 27 18 -> Expected Result
def multiply(a, b):
#your code
pass
Test.assert_equals(multiply(123, 456), [4, 13, 28, 27, 18]);
Test.assert_equals(multiply(42, 424), [16, 16, 20, 8]);