-- http://www.codewars.com/kata/541c8630095125aba6000c00
module DigitalRoot where

digitalRoot :: Integral a => a -> a
digitalRoot n = if n < 10
  then n
  else (digitalRoot . sum . map (`mod`10) . takeWhile (>0) . iterate (`div`10)) n