The Britney Spears Problem
americanscientist.org
americanscientist.org
Here's an easy brain teaser: do the above using only two registers.
I have used a similar trick (with a fixed N) to implement a cheap running average for an image acquisition software and it works quite well, but of course if N is very large val / N becomes negligible.