P27, P28: Added Mathematica solution.
P28: Updated Java and Haskell solutions.