New Reply

Number of digits in a number?

 
Share Thread Thread Tools
Feb23-11, 09:16 AM   #1
 

Number of digits in a number?


I was playing around with my calculator and I noticed that to calculate the number of digits in a number n we have # of digits in n = [log(n) + 1], where log is in base 10 and [] represents the floor function. I after looked this up and it seems like its true. But how would you go about proving something like this? I thought of writing n as its decimal expansion, and then taking the logarithm, but it doesn't seem to get me no where. Any ideas?
PhysOrg.com
PhysOrg
science news on PhysOrg.com

>> Bird's playlist could signal mental strengths and weaknesses
>> Minus environment, patterns still emerge: Computational study tracks E. coli cells' regulatory mechanisms
>> Bacterium uses natural 'thermometer' to trigger diarrheal disease, scientists find
Feb23-11, 10:00 AM   #2
 
Blog Entries: 8
Recognitions:
Gold Membership Gold Member
Science Advisor Science Advisor
Retired Staff Staff Emeritus
Let x be a number, then it is easy to see that

x has n digits if and only if [tex]10^{n-1}\leq x<10^{n}[/tex].

If we apply your expression on this, then we obtain

[tex]n=\log(10^{n-1})+1\leq \log(x)+1<\log(10^n)+1=n+1[/tex]

This yields that [tex][\log(x)+1]=n[/tex].
Feb23-11, 10:01 AM   #3
 
Recognitions:
Gold Membership Gold Member
Science Advisor Science Advisor
Retired Staff Staff Emeritus
A number, n, has "d" digits if and only if [itex]10^{d-1}\le n< 10^d[/itex]. Take the logarithm (base 10) of each part of that, using the fact that logarithm is an increasing function.
Feb23-11, 10:13 AM   #4
 

Number of digits in a number?


Ahhh didn't think of that. Thanks a lot to both of you! :)
Feb23-11, 07:41 PM   #5
 
Quote by Buri View Post
Ahhh didn't think of that. Thanks a lot to both of you! :)
Note that this can be generalized to any base b system. In particular, the number of bits needed to represent a number in base 2 is the log of that number to the base 2. This is really important in the analysis of algorithms.
Feb23-11, 09:27 PM   #6
 
Quote by Robert1986 View Post
Note that this can be generalized to any base b system. In particular, the number of bits needed to represent a number in base 2 is the log of that number to the base 2. This is really important in the analysis of algorithms.
Funny how you actually mentioned algorithms. I actually got into this problem by looking at the efficiency of the Euclidean Algorithm. I was trying to show that when the Euclidean Algorithm is applied to a and b (a > b) that it terminates in at most 7 times the number of digits of b.
New Reply
Thread Tools


Similar Threads for: Number of digits in a number?
Thread Forum Replies
Divisibility by 11 for all palindromes with an even number of digits Calculus & Beyond Homework 6
A three-digit number is drawn out of the digits from 0-9. Set Theory, Logic, Probability, Statistics 1
100cr digits number writing a paper General Math 15
Number of digits in n! Programming & Comp Sci 8
Question about determining digits of a number Precalculus Mathematics Homework 1