Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

An interview question - implement Biginteger Multiply

Tags:

math

Implement Biginteger Multiply

  1. use integer array to store a biginteger like 297897654 will be stored as {2,9,7,8,9,7,6,5,4}
  2. implement the multiply function for bigintegers
    Expamples: {2, 9, 8, 8, 9, 8} * {3,6,3,4,5,8,9,1,2} = {1,0,8,6,3,7,1,4,1,8,7,8,9,7,6}

I failed to implement this class and thought it for a few weeks, couldn't get the answer.

Anybody can help me implement it using C#/Java? Thanks a lot.

like image 726
superche Avatar asked Jul 09 '10 03:07

superche


1 Answers

Do you know how to do multiplication on paper?

  123
x 456
-----
  738
 615
492
-----
56088

I would just implement that algorithm in code.

like image 50
Paige Ruten Avatar answered Sep 18 '22 14:09

Paige Ruten