# What is the maximum length of the multiplication of two integers?

- Posted on

- Authors
- Name
- ansidev
- @ansidev

## Question

Given two non-negative integers `m1`

and `n1`

, `m1`

has `m`

digits and `n1`

has `n`

digits. `p1`

is the product of `m1`

and `n1`

(`p1 = m1 x n1`

), `p1`

has `p`

digits.

What is the maximum value of `p`

?

## Answer

- 0 ≤ m1 ≤ 10
^{m}- 1 - 0 ≤ n1 ≤ 10
^{n}- 1 - 10
^{k}- 1 is an integer has k digits of 9

```
10^k - 1 = 9.....9
|_____|
k digits of 9
```

```
10^k - 1 = 9.....9
|_____|
k digits of 9
```

p1 = m1 x n1 ≤ (10^{m} -1) x (10^{n} -1)

= 10^{m+n} - 10^{m} - 10^{m} + 1

= 10^{m+n} - 1 - (10^{m} - 1) - (10^{m} - 1)

≤ 10^{m+n} - 1

So, p1 can have maximum `m + n`

digits.