*Originally published 2012-03-23.*

Just starting out on your own? Brown-bag it for lunch and save $5 per day 5 times a week for 40 years. Invest that $5 each day, and how much will you have when you retire?

It's hard to find a reasonable lunch anywhere for much under $6 or $7, and it's easy to spend much more. But a good home-made lunch can be made for only a dollar or two, so buying your lunch instead of bringing it from home can easily cost you $5 or more every day.

That's only $25 per week, though, and what's that in the grand scheme of things? Over the course of a 40-year work career it turns out to be a lot.

It adds up even more -- a *lot more* -- if you consider the amount you could accumulate by investing the savings and compounding the earned interest. A bank savings account earns a percentage point or so these days. The total return on the S&P 500 stock index from 1950 to 2009 came out to 11% annually. A few savvy investors do better, and many do worse. Pick a rate of return, a term, and how much you can save each lunch, and let the calculator tell you what that burger and fries is *really* costing you.

This uses the formula for periodic compounding found on Wikipedia and makes the assumption that you do not save extra lunch money on weekends. It is rather simple-minded in that it does not figure out the number of days until the next compounding period. That is to say, if you choose to compound quarterly (4 times a year), it just plugs that interval into the formula without trying to figure out on which calendar days the interest will be calculated. Your actual return may vary slightly, but you can still see that it pays well to save your lunch money.

What this doesn't tell you is what years of inflation will do to your savings, nor does it consider taxes. Those stories are not nearly so nice.

Feel free to inspect the JavaScript code doing the calculation here:

```
/*
* $Revision: 1.1 $
* $State: Exp $
*
* ----------------------------------------------------------------------------
* From http://egb13.net/
*
* Copyright (C) 2011 by EGB13.net
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* ----------------------------------------------------------------------------
*
* Just starting out on your own?
* Brownbag it for lunch and save $5 per day 5 times a week for 40 years.
* Invest that $5 each day, and how much will you have when you retire?
*
* C.f.: http://en.wikipedia.org/wiki/Compound_interest
* ----------------------------------------------------------------------------
*/
function CompoundReturn (years, interest, periodicity, saved) {
var sum = 0 ;
var wday = 0 ;
var today ;
var totdays = Math.floor(years * 365.25) - 1 ; // a 1/4 day accounts for leap years
var r = interest / 100.0 ;
for (today = 0 ; today <= totdays ; today++) {
if (wday != 5 && wday != 6) { // skip weekends!
sum += saved * Math.pow( (1 + (r / periodicity) ), (periodicity * ( (totdays-today)/365.25) ) ) ;
}
wday++ ; if (wday >= 7) wday = 0 ;
}
sum = Math.round (sum * 100) / 100 ;
// sum = Math.round (sum) ;
sumstr = sum.toLocaleString('en-US') ;
var resultstring = "$" +saved+ " saved per day, 5 days a week, and invested at " +interest+ "% compounded " +periodicity+ " times per year.<br />After " +years+ " years, retire with about <b class='holycow'>$" +sumstr+ "</b> in the bank!" ;
document.getElementById('results').innerHTML = resultstring ;
}
```