Download

How to add a certain quantity of "zeros" to a number?

Hello all!

I was thinking in away of adding zeros to number. For example I have “2” and I want to add a random quantity of zeros to this number, in this case I will add “5” zeros to it and my result will be “200000”.

Does any one has any idea on how to do this? :confused: :smiley:

a110aaf1a8f57a5b6c3f7b97fd0f3a276d1932f0.png

There might be a much better way I can’t think of at 1 in the morning.

The top solution doesn’t really look like bruteforce. It simply access the array. Nothing really hurting performance.

However the lower solution is the one I would recommened too.

5 * 10 = 50

5 * 100 = 500

So you simply want to make sure you multiply with 10^X, where X is the number of zeroes you want.