2

After looking for the number of digits of a given number, I found this Brilliant page that says that given an integer $n$, one can determine $j$, the number of digits in $n$, by working with the inequality $10^{j - 1} \leq n \leq 10^{j} - 1$. By taking the base $10$ logarithm, $j - 1 \leq \log_{10} n < j$, so that $j - 1 = \lfloor \log_{10} n \rfloor$.

What I actually don't understand is the change of signs from $n \leq 10^{j} - 1$ to $\log_{10} n < j$ and the passage $j - 1 \leq \log_{10} n$ to $j - 1 = \lfloor \log_{10} n \rfloor$. I also read the answer to this question in the forum but the inequalities are slighty different from the ones of Brilliant. Could you help me out? (Sorry if the questions is ill-posed or confusing)

  • 1
    $$10^{j-1}\le n\le 10^j-1\lt 10^j\iff j-1\leq\log_{10}n\lt j$$ Since $\log_{10}n$ is not an integer when $n$ is not a power of $10$, you take the floor function to convert it to the greatest integer less than or equal to $\log_{10}n$ and equate it with $j-1$ – Prasun Biswas Jan 31 '21 at 00:13
  • 1
    If $n\le 10^j-1$, then $n<10^j$, and therefore $\log_{10}n<j$. Then we have $$j-1\le\log_{10}n<j,,$$ where $j-1$ and $j$ are consecutive integers, so clearly $j-1$ is the largest integer less than or equal to $\log_{10}n$, or inn symbols, $\lfloor\log_{10}n\rfloor=j-1$. – Brian M. Scott Jan 31 '21 at 00:14
  • The inequalities in my old answer to which you linked are actually the same as the ones at Brilliant, apart from the fact that I used $d$ rather than $j$ and went immediately to $n<10^d$ instead of bothering with $n\le 10^k-1$, since the two are clearly equivalent for integer $n$. – Brian M. Scott Jan 31 '21 at 00:18
  • @BrianM.Scott, thank you for your comment. After giving it some thought, now I understand the manipulations. – Raphael Ferreira Jan 31 '21 at 00:22
  • Thank you very much, @PrasunBiswas. – Raphael Ferreira Jan 31 '21 at 00:25
  • @RaphaelFerreira: You’re very welcome. – Brian M. Scott Jan 31 '21 at 00:27

0 Answers0