Login | Register
Nerd ParadiseArtisanal tutorials since 1999
Python Code Golf
Current challenge:
"Determine if a sentence is a palindrome."

Current shortest code:
70 bytes

Current contest ends:
1579996800, F jS, g:i A
Give it a try
Calculating base 10 logarithms in your head on the fly is a lot easier than you may think. It is simply a matter of memorization and a little estimation...

First memorize all the single digit base 10 logs. Don't worry, it's not as painful as it sounds. I even made the chart for you:
Log Base 10 of...Is equal to...

Remember this rule from high school?
log(a*b) = log a + log b

And what about this one, you remember it too?
log(10n) = n


Example #1: base 10 log of 400

That's the same thing as log(4*100) which equals log 4 + log 100. log of 4 you know from the table above. Log of 100 is log of 102 and therefore is equal to 2. So the log of 400 is 2 + log 4 which is 2.602. It might sound like a tedious method but try a few examples first and you will see it's actually pretty quick.

Now you may ask, what if it isn't just a number with a bunch of 0's after it?

Example #2: base 10 log of 35

Suppose you wanted to find the logarithm of 35. This is the same thing as log(3.5 * 10). The log of 3.5 is somewhere between the log of 3 and 4, but somewhat above the midpoint (since the log scale gets smaller as you go up). Log of 3 is .477 and log of 4 is .602 so we'll make a rough guess around .54 or .55 ish. Log of 10 is obviously 1, so our guesstimate for the log of 35 will be 1 + 0.545.

Our guess: 1.545
Calculator says: 1.544068...

Now you can convince all your friends and teachers that you are a robot.

Example #3: base 10 log of 290438572:

This is fairly close to log(2.9 * 100000000) = log 2.9 + log 108

2.9 is close to 3. Log(3) = .477, so we'll guess something slightly below that like .45

Our Guess: 8 + .45 = 8.45
Calculated Answer: 8.46305...

Now run off and scare some people with your new powers.