+0

# Number repeat function.

0
194
4
+20

It should work like this:
$$f(5, 3) = 555$$

$$f(12,3)=121212$$

$$555=5\cdot10^2+5\cdot10^1+5\cdot10^0$$

$$121212=12\cdot10^4+12\cdot10^2+12\cdot10^0$$

We see that the power of ten dependence on the length of the number that we're repeating.

Knowing this we can bring out the formula.

$$rep\left(x,n\right)=\sum_{c=0}^{n-1}x\cdot10^{c\lfloor\log10x\rfloor}$$

Where $$x\in\mathbb{N}$$ (x is the repeating number)

Where $$n\in\mathbb{N}$$ (n is the number of repetitions)

$$\lfloor\operatorname{log}10x\rfloor$$ - length of x

$$rep\left(5,3\right)=555$$

$$rep\left(12,3\right)=121212$$

Look at this on Desmos: https://www.desmos.com/calculator/4baj3yaxaz

off-topic
Sep 23, 2019
edited by JoshuaGreen  Oct 22, 2019

#1
+24365
+3

It should work like this:
$$f(5, 3) = 555 \\ f(12,3)=121212 \\ \\ 555=5\cdot10^2+5\cdot10^1+5\cdot10^0 \\ 121212=12\cdot10^4+12\cdot10^2+12\cdot10^0$$

We see that the power of ten dependence on the length of the number that we're repeating.

Knowing this we can bring out the formula.

$$rep\left(x,n\right)=\sum_{c=0}^{n-1}x\cdot10^{c\lfloor\log_{10}x\rfloor}$$

Where  (x is the repeating number)

Where  (n is the number of repetitions)

$$\lfloor log_{10}x\rfloor$$ - length of x

Sorry there is a mistake:

The length of $$x$$ is $$\mathbf{\lfloor log_{10}x\rfloor +\color{red} 1 }$$

$$\large{rep\left(x,n\right)=\sum \limits_{c=0}^{n-1}x\cdot10^{c \left( \lfloor\log_{10}x\rfloor+1 \right) }}$$

see Desmos:

hint:

$$\begin{array}{|rcll|} \hline &&\mathbf{ \lfloor\log_{10}x\rfloor+1 } \\ &=& \lfloor\log_{10}x+1 \rfloor \\ &=& \lfloor\log_{10}x+\log_{10}(10) \rfloor \\ &=&\mathbf{ \lfloor\log_{10}(10x) \rfloor } \\ \hline \end{array}$$

see Desmos:

Sep 24, 2019
#2
+1

Thank you again. Your responses are really great. Every time you give me such useful information. Where do you get these hints? I need to know them all!

Guest Sep 24, 2019
#3
+20
+1