Posted by: Gary Ernest Davis on: November 13, 2010

The

I tweeted:

republicofmath 2^n begins with 9 for n = 53, 63, 73, 83, 93, 156, 166, 176, 186, 249, 259, 269, 279, 289, 352, 362, 372, 382, 445, 455, 465 … #MathsJam

x

Following my tweet Barb Lynch asked:

Stelladuma @republicofmath How did you get the solutions for 2^n beginning with 9?

x

My answer was short and straight to the point (I had used Mathematica) but not explanatory:

republicofmath @Stelladuma 2^n beginning 9? #Mathematica: L = {}; Do[If[IntegerDigits[2^n][[1]] == 9, L = Append[L, n], L = L], {n, 1, 750}]; L #mathsjam

x

x

Barb Lynch, from Northeast Ohio, USA, is a teacher of algebra 1 and geometry to G/T middle school students. Chances are Barb does not have an available copy of Mathematica, and it’s highly likelyÂ her students do not have access to Mathematica even if she does.

x

So, if we are to adopt a computational solution to finding the powers of 2 that begin with 9, it would be handy to have another computational engine that students did have access to.

x

Enter a spreadsheet.

x

I will use Excel, but an open source spreadsheet, including that on Google Docs will do.

x

All we need from a spreadsheet is built-in functions for:

- logarithms to the base 10
- finding the whole number part of a decimal number
- the ability to form powers.

All spreadsheets can do these things.

x

The idea is that we will generate a list of powers of 2 and examine that list to see which entries begin with a 9.

x

The one trick we need is to figure out how to extract the leading digit from a number such as “123′ when it is written in the spreadsheet.

x

Of course as human beings we just look to the left and speak the digit.

x

The question is: how do we instruct a spreadsheet to to do that?

x

The answer, it turns out, is surprisingly easy, using the miraculous powers of indices (otherwise known by the mysterious name of “logarithms”).

x

Here’s the idea:

- To figure out how many powers of 10 are involved in a number such as 123, we take the logarithm, base 10, of the number. This makes sense because . So, for example, .
- To figure out what whole number of powers of 10 are involved in a number, such as 123 we drop the fractional bit of to get 2. To do this in the spreadsheet we use the function “int” which takes the integer part of a decimal number.
- Now we have now that 123 is in the range we need to divide by this number to figure how many of these powers of 10 we have. So we divide 123 by to get 1.23.
- Now we are pretty much there: if we take the integer part of this number, using “int” we get 1. Voila! We have the leading digit of our number.

So here’s a how we might implement this in a spreadsheet (click on the image to enlarge it):

What do these spreadsheet formulas mean?

- In the first column we are just creating a list of integers 1, 2, 3, 4, … by beginning with 1 and adding 1 at each step.
- In the second column we are forming where n is the corresponding entry in the first column.
- In the third column we are taking the logarithm, base 10, of the corresponding number in the second column.
- In the fourth column we are finding the whole number part of the decimal number in the third column.
- In the fifth column we are dividing the corresponding number in the second column () by 10 raised to the power in the fourth column.
- In the sixth column we are taking the whole number part of the decimal number in the fifth column.
- In the seventh column we asking the spreadsheet to say “YES” if the number in the sixth column is 9 (and “NO”otherwise)

When we do this without displaying formulas, ax I have done above, but just showingÂ numbers, we see that a “YES” first appears at n = 53, and another “YES” appears soon after at n = 63 (click on the image to enlarge it):

That’s it, from a computational perspective.

x

Pretty soon a spreadsheet will not be able to accurately calculate large powers of 2, so another computational engine needs to be used. That’s a story for another time.

Another fun observation is how many of those powers of 2 start with the digit 1: 30.1% of them in the long run. Then 17.6% start with 2, and so on. If you have a big slide rule around, you can show them the same proportions on the C or D scale. The same (first digit) thing works with our beloved Fibonacci numbers, and most any geometric sequence.

Here’s a solution in Python. Somewhat similar to the Mathematica solution, but Python is totally free and available to anyone.

>>> [n for n in range(1, 1001) if str(2**n)[0] == ‘9’]

[53, 63, 73, 83, 93, 156, 166, 176, 186, 249, 259, 269, 279, 289, 352, 362, 372, 382, 445, 455, 465, 475, 485, 548, 558, 568, 578, 641, 651, 661, 671, 734, 744, 754, 764, 774, 837, 847, 857, 867, 930, 940, 950, 960, 970]

Great post, thanks Michel for pointing me to this. I love seeing ways of using technology that imparts a valuable programming skill while giving students a deeper understanding of math (e.g. that 91 is 9*10+1).

I have blogged a bit about this here but I definitely need to give some more examples like this post.

http://brokenairplane.blogspot.com/2010/08/computer-science-programming-intro.html

1 | Dave Radcliffe

November 13, 2010 at 4:55 pm

You can also do this without logarithms. Just multiply by 2 each time, and divide by 10 when the result exceeds 10. (This could be useful if students have not studied logarithms yet.)

Gary Davis

November 13, 2010 at 5:01 pm

Thanks Dave. Always good to find a more direct, less complicated, way of doing things.