Towers of Hanoi

A friend of mine is starting a pretty fun looking math blog. His first post is on Towers of Hanoi. I'm sure he'll tackle it with some slick mathematics, but my usual M.O. is to convert everything to code. I remember this "Hello Recursive World" fromĀ SICP in Scheme; looks better in F#:


rec hanoi f x t n =
if n > 0 then
hanoi f t x (n - 1)
printfn "From %c to %c" f t
hanoi x f t (n - 1)

hanoi 'A' 'B' 'C' 8