# How to simplify this power equation?

I need a function such that if input is $n$ it outputs an $n$-digit number. I need a mathematical function.

For example:

\begin{align}\mathrm{ANY}(2) &= 22 \\ \mathrm{ANY}(3) &= 333 \\ \mathrm{ANY}(n) &= nnn\ldots n \quad (n \text{ times})\end{align}

I think $\mathrm{ANY}(n)$ is something like:

\begin{align}\mathrm{ANY}(2) &= (10^1 + 10^2) * 2 \\ \mathrm{ANY}(3) &= (10^1 + 10^2 + 10^3) * 3 \\ \mathrm{ANY}(n) &= (10^1 + 10^2 + \ldots + 10^n) * n\end{align}

My question is can we further simplify the equation: $10^1 + 10^2 + \ldots + 10^n$? Or is it not possible?

Additionally, I need just any $n$-digit number on $n$ input, not necessary like $22$, $333$, $4444$, $\ldots$. In case simplification is not possible then suggest me any other function? I have no much idea if its possible.
Also domain to my $\mathrm{ANY}$ function can be $1$ to $100$.

I need to solve some problem in computer science.

-
if my question is wrong I can remove it and try to find answer myself. – Grijesh Chauhan Mar 28 '13 at 19:24
what is to happen if $n>9$ – Maesumi Mar 28 '13 at 19:32
@Maesumi actually I just need any n digit number don't bothers if it 11111 11111 1 or 22222 22222 2 – Grijesh Chauhan Mar 28 '13 at 19:34

This one gives you only till $n\leq 9$. You could take the geometric series which says that $$\sum_{k=0}^n q^k = \frac{q^{n+1}-1}{q-1}$$ which is in your case $$\frac{1}{10}\cdot \left( \frac{10^{n+1}-1}{9}-1\right)\cdot n$$ the $-1$ is there because you don't have the naught term.

If you only want an arbitrary $n$ digit number take $$10^{n-1}$$ if you want alle the same digit take $$\frac{10^n-1}{9} \cdot \text{your favorite digit}$$

To get any number from 10 till 99 with your exact formula take $$\frac{1}{100} \cdot \sum_{k=1}^\frac{n}{2} 100^k \cdot n=\frac{1}{99} \cdot (10^n-1)\cdot n$$ for $n$ even and $$\frac{1}{10} \cdot \sum_{k=1}^\frac{n-1}{2} 100^k \cdot n + \left\lfloor\frac{n}{10}\right\rfloor=\frac{1}{99} (10^{n}-10)\cdot n +\left\lfloor\frac{n}{10}\right\rfloor$$

-
Note that when $n \geq 10$, the number of digits will be off. – Raymond Cheng Mar 28 '13 at 19:31
Yes I understood your equation. Thanks – Grijesh Chauhan Mar 28 '13 at 19:44
BTW what is naught term ? yes i confuse you people. – Grijesh Chauhan Mar 28 '13 at 19:46
It is the term for $k=0$ don't know if it is a usual expression – Dominic Michaelis Mar 28 '13 at 19:47
@GrijeshChauhan updated my solution try again, it gives you the wanted pattern :) – Dominic Michaelis Mar 28 '13 at 19:59

I suppose simpler functions would be $\mathrm{any}(n) = 10^{n-1}$, e.g. outputting $\mathrm{any}(3) = 100$, or $\mathrm{any}(n) = 10^n - 1$, e.g. outputting $\mathrm{any}(3) = 999$.

To get the exact function you specified, you could use the formula for geometric series to obtain $\mathrm{any}(3) = (\frac{10^{n} - 1}{9}) \cdot n$. Note that this does not give you an $n$-digit number for $n \geq 10$.

-
thanks :) sorry it was so simple I mean your first solution. – Grijesh Chauhan Mar 28 '13 at 19:43
@FixedPoint: Yes, that formula works, but the formula suggested by the OP leads to $\mathrm{any}(n)=(10^n-1)/9 \cdot n$ (note the extra $n$) which gets an unwanted extra digit once $n \geq 10$. – TMM Mar 29 '13 at 0:23

so if you are okay with

any(1)=1

any(2)=11

any(3)=111

and so on then $$any(N)=\frac{10^N-1}{9}$$ will work for any number of digits so the domain is all natural numbers. You can get a number with whatever number of digits you need.

-
Why the downvote? This any(N) does give you a N digit number for any natural number N. any(20)=11111111111111111111 – Fixed Point Mar 29 '13 at 0:16