Problem 1 solutions in C#, F#, Prolog, and Haskell