[I think the FWP list processor mangles the Reply-To: header, which read Reply-To: Ian.Phillipps@mail.com when it left here] On Wed, 18 Oct 2000 at 12:48:21 -0400, Ronald J Kimball wrote: > On Wed, Oct 18, 2000 at 12:37:45PM -0400, yanick1@sympatico.ca wrote: > > perlgolf hole - Digital Root > > Write a subroutine to compute the digital root of any whole number argument. > > Winner: sub hole {$_=pop;1while s/(\d)(\d)/$1+$2/ge;$_} I didn't know what a digital root was until Google pointed me to http://mathworld.wolfram.com/DigitRoot.html, but using the info on that page, I submit: sub hole {$_[0]&&($_[0]-1)%9+1} or this if you allow it to modify its parameter: sub hole {$_[0]&&$_[0]--%9+1} Neither this nor yanick1's submission behave correctly for negative numbers, whatever "correctly" means here. Ian ==== Want to unsubscribe from Fun With Perl? Well, if you insist... ==== Send email to <fwp-request@technofile.org> with message _body_ ==== unsubscribe