Stefan Ram <ram@zedat.fuberlin.de> wrote:
+
 Recently a question was posed in TV about the number of "5"
 characters occuring within all integral decimal numerals
 between 0 and 100.

 Frank Buss suggested the following source code to
 calculate the result in Lisp:
...
 I wrote this in Perl:
+
Actually, I don't like *any* of the (many) solutions presented! ;}
This is a problem you should be doing in your head! QUICK! What's
the answer for 09? One, of course. And the answer for 099? One
for each decade, plus 10 for the 50's, or 20 [as many responded].
What about 0999? 300. 09999? 4000. And 099999? 50000, duh!
Got the pattern yet...? ;}
There's some ancient aphorism about this, something about *thinking*
first, before haring off to write code. But, hey, Gauss got in a lot
of trouble for thinking [Google for "Gauss sum class"], so I suppose
nobody does that any more.
This one is only slightly harder: Among the printed representations
of integers from 0 to (expt 10 n), how many contain *at least one* "5"?
Hint: ((1 . 1) (2 . 19) (3 . 271) ... )
Rob

Rob Warnock <rpw3@rpw3.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)5722607