perlgolf hole - Digital Root

Hole type: subroutine

Adding up the digits of a non-negative integer produces a number:

1234567 -> 1+2+3+4+5+6+7 -> 28

Adding up those digits produces another:

28 -> 2+8 -> 10

Repeating this process until only a single digit is left produces a checksum known as a digital root:

10 -> 1+0 -> 1

Write a subroutine to compute the digital root of any non-negative integer argument.

Solution