2008-08-11 01:01:42

Calculate the sum of digits of a given number

echo 1234 | sed 's/\(.\)/\1\+/g' | sed 's/.$//' | bc -l
perl -e 'print eval join "+", split //, 12345;' 

Posted by haui | Permanent Link | Categories: linux