My golfed solution
perl -nle 'my$s;$t=$_;s/(\d)/$s+=$1**length/ge;print$t==$s'
prints 1 if a number is narcisistic and "" otherwise. It should work reliably for numbers that don't require exponents in their representations as doubles on your system. That's up to and including the narcisistic 28116440335967 for me. I'm sure someone can do better...
-sauoq "My two cents aren't worth a dime.";
In reply to Golf: Re: Mathematics ethics
by sauoq
in thread Mathematics ethics
by cored
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |