1

Let's say you have 2 numbers.

First number is always 6 digits long.

Second number can vary between 1 and 4 digits. If it's less than 4, it has to be padded with 0.

The end result always needs to be 10 digits.

Example #1:

n1 = 111111
n2 = 2222
result should be 1111112222

Example #2:

n1 = 111111
n2 = 22
result should be 1111110022

I know how to get that result in code by using string data type, padding the numbers and then concatenating (gluing) the numbers back together but I was wondering is there a mathematical way (by summing, dividing, multiplying the numbers) to get desired results?

HABJAN
  • 113

1 Answers1

2

$$ \text{result}=10^4\times n_1+n_2 $$