I thought the rule was slick, but when trying to do the math things just didn't add up. You can try constructing the recurrence relation yourself, or you can read moneychimp's explanation. The formula I got was to calculate the log of 2 (two for doubling), base (1 + r/100); it turns out the whole time that the rule of 72 is just an inverse linear approximation to the logarithmic function. But it is mostly right for the ranges people would care about. (For a rate of 5%, the log gives you 14.2 years, while the rule of 72 gives you 14.4; for a rate of 50%, the log gives you 1.7, while the rule of 72 gives you 1.44.)
f(x)=72/x is a really simple function, and when comparing the plots of the two functions it is pretty impressive how close it is:
I like the times when all of the math I've learned, even the basic concepts, become useful in analyzing other things. A computer scientist isn't trained in finance, but knowing that what you've learned can be applied widely can empower you.
I had a physics professor who once quipped "men see parabolic trajectories more often than women do." [So as not to leave it too cryptic, he was referencing stand up urinals.] It's an interesting way of thinking about gravity, and it once made me realize something: A friend in Worcester was showing me his "movie" gun (i.e., it wasn't real) and I considered the scope. I knew that scopes were meant for different target ranges, and it was then that I realized that a scope on a gun is a linear approximation to a parabola. Each scope setting is meant for different ranges, which approximates different parts of the parabola. (Also, they only work with Earth's gravity.) I mention guns in my blog only because, after explaining this to my friend he said something funny: "Man, I should totally take you out shooting; you'd be such a great target... I mean shot."
***Side note: If investment interests you, check out this piece on index funds by Scott Adams, author of Dilbert. The company referenced, Vanguard, is an excellent one due to its unique corporate structure: Customers are also shareholders in Vanguard, so the company always has the customer's best interests in mind. In our culture it's sometimes considered boorish to talk about money, but somebody's got to tell you about it! Particularly now that pensions are going away and that defined contribution plans are your responsibility, you should empower yourself by knowing as much as you can.