1
$\begingroup$

I am trying to figure out the mathematical relation between a number and the number of digits that number has.
For e.g. Relation between 0, 1, 2...9 and 1,

     or between 10, 11, 12...99 and 2,        or between 100, 101, 102...999 and 3,        or between 1000, 1001,...5000, 5001, ...9999 and 4. 

So given a number having 'n' digits whose value is 'x', I want to express it as

n = f(x) 

I could figure out the following:

x = ∑(10^i * xi)  where i=1 to n.  Where xi is the digit at position i. 

So x = x1 + 10*x2 + 10^2*x3 + ... + 10^n*xn

Where x1, x2, x3 etc. are digits at unit, tenth, hundredth positions respectively.

I am surely missing something here. Any help is appreciated

Thanks,

Sid

2 Answers 2

3

Is this what you want?

  • If a number $n$ has $k$ digits, then $10^{k-1} \le n < 10^{k}$.

  • If a number $n$ has $k$ digits, then $k = \lfloor\log n\rfloor + 1$ where $\log$ is to base $10$.

Replace $10$ with $b$ if you're using a different base $b$.

0

You are not missing anything.

A representation of a number $x$ in base $d$ is the (unique) sum $x=\sum_{i=0}^n a_id^i$ with $0\le a_i for all $0\le i\le n$ (the $a_i$'s are the digits in that base).

I'm not sure what else you want to find.

  • 0
    Yes. Kudos for ShreevastaR.2011-06-06