Is there a formula that predicts the amount of digits of the multiplication of two very large numbers?

gegogabanana

New member
Joined
Mar 21, 2024
Messages
7
Lets say you have two very big numbers X and Y and the number of digits for each respectively is m an n.
now lets multiply X and Y
X*Y=Z
is there then a formula of m and n that predict the number of digits Z has?
I know this has something to do with carrying over but since i dont have a big background in math i cant quite figure it out. If there even is such a formula.
If anyone knows it would be really helpfull.
 
Lets say you have two very big numbers X and Y and the number of digits for each respectively is m an n.
now lets multiply X and Y
X*Y=Z
is there then a formula of m and n that predict the number of digits Z has?

Think about the vertical multiplications you've done by hand. For each digit in the lower number, you'd get a row below that you would then add. Each row's start was shifted one place to the left. Thinking of those rows, you would have (as many digits as the top number, or maybe one more because of the "carry") in each row, with the number of rows being equal to the number of digits in the bottom number. Since each successive row's start was shifted one place to the left, then the last row would start at the place equal to the number of digits in the bottom number, so the number of empty spaces to the right of where you start that last row's digits would be equal to one less than the number of digits in the bottom number. Then, thinking of adding down, you would have as many columns as the sum of the digits in each of the original numbers (or maybe one more because of the carry).

For instance, suppose you wanted to know the number of digits in the following:

[imath]\qquad 12345 \times 567890[/imath]

This is (five digits) multiplied by (six digits). Each row in the multiplication (assuming we put the larger number on top) will have five (or maybe six) digits; the final row will start at the fifth column (under the [imath]1[/imath]), leaving four columns empty to its right. That final row will have five (or maybe six) digits to the right of those four empty columns. Adding down then, you'll have (the number of digits in the larger number) plus (one less than the number of digits in the smaller number) or maybe one more because of the carry. This means that the number of digits should be [imath]6 + 4[/imath] or maybe [imath]6 + 4 + 1[/imath].

The product is [imath]7,010,602,050[/imath], which has ten digits. This matches our expectation.

So what sort of formula can you derive from this?
 
Lets say you have two very big numbers X and Y and the number of digits for each respectively is m an n.
now lets multiply X and Y
X*Y=Z
is there then a formula of m and n that predict the number of digits Z has?
I know this has something to do with carrying over but since i dont have a big background in math i cant quite figure it out. If there even is such a formula.
If anyone knows it would be really helpfull.
Another helpful formula: [math]\log_{10} (Z) = \log_{10} (X) + \log_{10}(Y)[/math]
 
Thanks for the quick reply. I’ll send a reply in this thread when I’ve finished what I wanted to do with the formula.
 
Ok i've got another question. now that you know the amount of digits a number has, how can you than find each digit of the sequence. I know this is just what multiplication is but I want a more subtle way to do this.
essentially what im looking for is a way to write the math behind the japanese multiplication method for large numbers in a general form.

what i've found is this: 23 x 12 = (2x10 + 3)(1x10 + 2) = 2x1x102 + [2x2x10 + 3x1x10] + 3x2 = 276
but i dont know how to generalize this into a formula for larger numbers.

thanks in advance :)
 
Consider 25*18=450 and 99*90=8910. Both multiplications involve multiplying two 2-digit numbers. In one case we end up with a 3-digit number while in the other case we end up with a 4-digit number. You can't predict exactly how many digits will result in multiply a n-digit number by a m-digit number.
 
Lets say you have two very big numbers X and Y and the number of digits for each respectively is m an n.
now lets multiply X and Y
X*Y=Z
is there then a formula of m and n that predict the number of digits Z has?
Consider 25*18=450 and 99*90=8910. Both multiplications involve multiplying two 2-digit numbers. In one case we end up with a 3-digit number while in the other case we end up with a 4-digit number. You can't predict exactly how many digits will result in multiply a n-digit number by a m-digit number.
In fact, you can work out the smallest and largest possible numbers of digits. For example, for 3 digits times 4 digits, the smallest possible result is 100*1000 = 100,000 (6 digits), and the largest is 999*9999 = (1000-1)(10000-1) = 10,000,000 minus a little (7 digits).

So, generalizing this, what is the rule? (It can be stated not "you will get __ digits", but "you will get about __ digits", or "you will get __ or __ digits".
 
If [imath]D(n)[/imath] is the number of digits, decimal or some other base, for [imath]n[/imath] it can be shown that [imath]D(m)+D(n)-1 \leq D(mn) \leq D(m)+D(n)[/imath], i.e. it is either the sum or one less than the sum.
 
In fact, you can work out the smallest and largest possible numbers of digits. For example, for 3 digits times 4 digits, the smallest possible result is 100*1000 = 100,000 (6 digits), and the largest is 999*9999 = (1000-1)(10000-1) = 10,000,000 minus a little (7 digits).

So, generalizing this, what is the rule? (It can be stated not "you will get __ digits", but "you will get about __ digits", or "you will get __ or __ digits".
Yes, I know that. However the OP stated Lets say you have two very big numbers X and Y and the number of digits for each respectively is m an n. now lets multiply X and Y X*Y=Z, Is there then a formula of m and n that predict the number of digits Z has?
The answer to that question is no. I guess that I could have given a range.
 
Yes, I know that. However the OP stated Lets say you have two very big numbers X and Y and the number of digits for each respectively is m an n. now lets multiply X and Y X*Y=Z, Is there then a formula of m and n that predict the number of digits Z has?
The answer to that question is no. I guess that I could have given a range.
These days there's no difficulty calculating the result of the multiplication of two large numbers (\(\displaystyle X\) & \(\displaystyle Y\)), so, just forgetting all about m & n, surely the formula:-

[math]|\log_{10}(X\times Y)|+1[/math]would produce the desired result?
 
Last edited:
These days there's no difficulty calculating the result of the multiplication of two large numbers (\(\displaystyle X\) & \(\displaystyle Y\)), so, just forgetting all about m & n, surely the formula:-

[math]|\log_{10}(X\times Y)|+1[/math]would produce the desired result?
I assume you meant something like [math]\left\lfloor\log_{10}(X\times Y)\right\rfloor+1[/math]
The absolute value isn't needed, but the floor is.

Of course, the answer to the question as intended ("a formula [in terms] of m and n") is [math]m+n-1\text{ or }m+n[/math]
 
I assume you meant something like [math]\left\lfloor\log_{10}(X\times Y)\right\rfloor+1[/math]
The absolute value isn't needed, but the floor is.

Of course, the answer to the question as intended ("a formula [in terms] of m and n") is [math]m+n-1\text{ or }m+n[/math]
Yes, of course, that is what I should have written. I don't know what I was thinking when I used 'Absolute brackets' instead of 'Floor brackets'! 😖 (Maybe just because I was rushing and they're easier to type? 🤪🤔🤷‍♂️ But there's no excuse, it was just a bad error on my part! 🙇‍♂️ Thank you for correcting it @Dr.Peterson. 🙏)

However, the point I was trying to make is that, although the OP did ask for a formula involving the use of the number of digits in the factors (m & n in the OP), as @Steven G (and now you) have pointed out, there is no such formula that can give a single answer to that question as there will always be two possibilities.

Therefore, it seems to me that the desired outcome can be more easily and accurately obtained by actually performing the multiplication (which almost any modern device can do in a small fraction of a second) and then calculating the (actual) number of digits in the final product by using, as you have (correctly) rewritten it:- [math]\left\lfloor\log_{10}(X\times Y)\right\rfloor+1[/math]That was all I was trying to say.

Perhaps @gegogabanana might now come back and tell us what s/he thinks of the comments that have been offered in response to their OP
 
Afterthought:-

If m & n were determined by \(\displaystyle \log_{10}X\) and \(\displaystyle \log_{10}Y\) respectively, wouldn't this formula work?

[math]\left\lfloor\log_{10}X+\log_{10}Y\right\rfloor+1[/math]
 
Lets say you have two very big numbers X and Y and the number of digits for each respectively is m an n.
now lets multiply X and Y
X*Y=Z
is there then a formula of m and n that predict the number of digits Z has?
I know this has something to do with carrying over but since i dont have a big background in math i cant quite figure it out. If there even is such a formula.
If anyone knows it would be really helpfull.
How do you arrive at the values of m and n for X and Y?
Is it by some kind of $String function or do you just physically count the number of digits?
 
How do you arrive at the values of m and n for X and Y?
Is it by some kind of $String function or do you just physically count the number of digits?
In most ordinary contexts, the first thing you know about a large number is its size: "23 million ..." tells you immediately that it has 8 digits (unless, in the end, you find it isn't an integer!).

We don't know the context here; you are suggesting a programming context, but we don't know at all. In that context, you might know the number of bits used to store a number, which could be relevant (but you'd be most interested in the number of bits needed for the product). Or you might know the maximum size of each input.

@gegogabanana, can you please respond, so we can have some idea what you really need?
 
In most ordinary contexts, the first thing you know about a large number is its size: "23 million ..." tells you immediately that it has 8 digits (unless, in the end, you find it isn't an integer!).

We don't know the context here; you are suggesting a programming context, but we don't know at all. In that context, you might know the number of bits used to store a number, which could be relevant (but you'd be most interested in the number of bits needed for the product). Or you might know the maximum size of each input.

@gegogabanana, can you please respond, so we can have some idea what you really need?
Indeed and thank you for that valuable contribution.
However, I wasn't actually seeking further exposition from the 'community'.

My questions were aimed directly at @gegogabanana.

As you say, we need to know the context here and that can only be provided if the OP deigns to respond.

What are the chances? Eh? 🤣
 
sorry guys im a bit of a chaotic person, and i know this is a bit off topic for this thread. but i'm playing around with perfect numbers.

So what i've found is cool but i don't know if it's arbitrary or anything. (i needed the formula to estimate the amount of digits of the perfect number formula but i decided to go another way about it)

so if you decompose a perfect number into the form of 0.X where X is the perfect number.
example 6 --> 0.6 or 6/10.

i did this for each digit in the perfect number. the next step was to find the common divisors of each of the digits. for 6/10 that's 3; for 20/100 8/100 its 6 and 3 repectively. and so on.

now i had a the following table:
1st (x)3
2nd (y)63
3rd (z)1242
4th (g)16964
5th (t)644942290942
6th (r) 110908849543016062

So the next thing i did is a bit diabolical XD

i started dividing them as follows:
x/y = 3/6/3 = 3/2 = 1.5
x/y/z = 3/2/12/4/2 = 1/64
x/y/z/g = 3/2/12/4/2/16/9/6/4 = 1/221184
and so on.

now at this point i was only intrested in the denominator. so here is what i've found if you take each denominator and you look for the closest prime that is higher and lower than the denominator you find that they are always a prime number away. Except 6 but it's always except 6

example:
1/64 ---> 64 nearest primes 67 and 61 (3 up and 3 down)
221184 nearest prime 221197 and 221173 (13 up and 11 down)
x/y/z/g/t = 1/60828841672704 nearest prime is 73 up and 5 down
x/y/z/g/t/r = 1/807680758149948855287808000 nearest prime is 31 up and 41 down
x/y/z/g/t/r/8th perfect number sequence = 1/2264977230337753192415723672273367859200000000 nearest prime is 73 up and 41 down

so this is what i've found, is there a natural explanation for this? and is it usefull?

i also found that adding the individual fractions together does some stuff and so on

ps. i calculated everything using wolfram alfa and checked the primes using numberempire.com
 
i needed the formula to estimate the amount of digits of the perfect number.
It really would have been nice if you said that you just wanted an estimate.
Are you sure that you know what a perfect number is? Below are the first few prime numbers.
35496
478128
51333550336
6178589869056
719137438691328
 
i needed the formula to estimate the amount of digits of the perfect number.
It really would have been nice if you said that you just wanted an estimate.
Are you sure that you know what a perfect number is? Below are the first few prime numbers.
35496
478128
51333550336
6178589869056
719137438691328
yes and if you then divide them by 10^amount of digits you get the fraction. so for 8128 is becomes 8128/10000. which you can write as 8000/10000 + 100/10000 + 20/10000 +8/10000. now if you find the amount common divisors for each fraction you get 16 for the first 9 for the second term 6 for the third term and 4 for the last term.
this is how i got the table i wrote down.

so the table arent the perfect numbers but a operation done with perfect numbers.

and then divide them and you get the result i posted.
 
Top