Multiplying numbers splitting the number into 4 digit numbers

194 Views Asked by At

Doing some programming exercise how to sum big numbers,I split the numbers into $n$ numbers of $4$-digit numbers $1240135981395813958$ I split into $1240$,$1359$,$8139$,$5813$,$958$ and summing with $94314314134134134134$ I split into $9431$,$4314$,$1341$,$3413$,$4134$ and summed accordingly $9431+1240$,$4314+1359$,$1341+8139$,$5813+3413$,$4134+958$ and if some number is $5$-digit I would add $1$ to digit on the left.I thought about the same process for multiplication,my thought was to write both numbers as $$a=\sum_{k=0}^n (10^3a_{4k+3}+10^2a_{4k+2}+10a_{4k+1}+a_{4k})\cdot 10^{4k}\\b=\sum_{k=0}^n(10^3b_{4k+3}+10^2b_{4k+2}+10b_{4k+1}+b_{4k})\cdot 10^{4k}\\ab=(\sum_{k=0}^n (10^3a_{4k+3}+10^2a_{4k+2}+10a_{4k+1}+a_{4k})\cdot 10^{4k})(\sum_{k=0}^n(10^3b_{4k+3}+10^2b_{4k+2}+10b_{4k+1}+b_{4k})\cdot 10^{4k})$$ but have no idea how to group terms with powers of $10$

1

There are 1 best solutions below

0
On BEST ANSWER

I'd think of the numbers in base $10000$.

So,

$124,0135,9813,9581,3958 = \\ 124 \times 10000^4 + 0135 \times 10000^3 + 9813 \times 10000^2 + 9581 \times 10000^1 + 3958 \times 10000^0$

and

$9431,4314,1341,3413,4134 = \\ 9431 \times 10000^4 + 4314 \times 10000^3 + 1341 \times 10000^2 + 3413 \times 10000^1 + 4134 \times 10000^0$

Your product is $25$ terms with $(1,2,3,4,5,4,3,2,1)$ terms having power $(0,1,2,3,4,5,6,7,8)$.

Group like powers of $10000$ together and carry the sums for each power to the next higher power as needed, just like you would for base $10$.