A digital root, according to Wikipedia, is "the number obtained by adding all the digits, then adding the digits of that number, and then continuing until a single-digit number is reached."
For instance, the digital root of 99 is 9, because 9 + 9 = 18 and 1 + 8 = 9.
My Haskell solution -- and I'm no expert -- is as follows.
digitalRoot n
|
…