Challenge description
Multiplification (totally not a made-up word) is a process in which you take two positive integers: a
and b
, and produce another integer which is equal to a
repeated ("glued together") b
times. For example, multiplifying 3
by 7
gives 3333333
. Similarly, 103
multiplified by 5
is 103103103103103
.
In this challenge, given two positive integers a
and b
, output a
multiplified by b
. The catch is, you can't use string operations to generate the number - it has to be done in a purely mathematical way. You may only use operators for addition (+
), subtraction (-
), multiplication (*
), integer division (/
, //
, div
), modulo operation (%
, mod
) and binary operations (&
, ^
, |
, <<
, >>
etc.). It's not possible to do in every language, since it has to support arbitrary precision integers.
Sample inputs / outputs
10, 4 | 10101010
3, 9 | 333333333
3737, 2 | 37373737
993, 1 | 993
8888, 8 | 88888888888888888888888888888888
[3, 2] -> 32
unless you do it mathematically, that is for example3*10 + 2
. The point is not to use string operations. \$\endgroup\$a
to count its length and another to multiply by the corresponding g.p. \$\endgroup\$