The number of digits in numbers between 0
and $n^2-1$ of base n
is obtained by
$\log_n(n^2) = 2\log_nn = 2$
But why log is being used? I mean how doing log gives correct answer always?
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It only takes a minute to sign up.
Sign up to join this communityIn base $n$, $n$ is represented as $10_n$. So $$10_n^2 = 100_n$$ That's 3 digits.
Now $1+\log_n(n^2) = 3$. Done.
About the number of digits of a number $n^2$ in base $b$:
Let $n$ have the representation $$ n = (d_{m-1} \cdots d_1 d_0)_b = \sum_{k=0}^{m-1} d_k b^k $$ with $m$ digits from $\{ 0, \ldots, b-1 \}$. Then we have $$ n < b^m \Rightarrow n^2 < b^{2m} $$ This means $n^2$ has at most $2m-1$ digits.
To derive $m$ for a given $n$ we use some logarithm: $$ n < b^m \Rightarrow \\ \log n < \log b^m = m \log b \Rightarrow \frac{\log n}{\log b} < m $$ The smallest $m$ should be $$ m = \left\lfloor \frac{\log n}{\log b} \right\rfloor + 1 $$ The special case $b = n$ gives $m = 2$ and that $n^2$ has at most $3$ digits.
As pointed out by fellow users $n^2 = (100)_n$ has exactly $3$ digits, which means that your formula, which gives $2$ digits, is not correct.
n
of base The number of digits in the square of a number $n$ of base $n$ is $3$ regardless of the value of $n$. Why make things any more complicated than that??? $\endgroup$