Sunday, February 22, 2009

HW 5 solutions

The solutions to Homework 5 are out.

Just for 'fun,' I included code snippets in various languages to solve the last problem, in which you needed to sum the harmonic series over 75 terms. Actually, I wrote quick versions in several languages, such was the depth of my procrastination. Represented are
  • C (iterative and recursive solutions)
  • Pascal
  • Perl
  • LISP
  • Python
  • Java
  • shell (bash) script
  • Postscript
  • Fortran
If you are similarly bored, how about some submissions in other languages? Or perhaps some particularly obfuscated solutions in some of the languages above?

(In particular, my postscript solution could be fancied up quite a bit for prettier output. The bash script is also a bit cheap and approximate, since one can only use integers.)

2 comments: