title: Sum digits of a number while greater than 2 digits
body: <p>The challenge is to sum the digits of a given number till the result has only one digit. Let say the number is "999" (9+9+9=27, 2+7=9). This is what I did till now.</p>
  
  <pre><code>#!/bin/bash
  set +m
  shopt -s lastpipe
  
  NUMBER=999
  
  DIGITS=`echo "${#NUMBER}"`
  FINALSUM=0
  
  if [ "$DIGITS" -gt 0 ] &amp;&amp; [ "$DIGITS" -gt 1 ]; then
      grep -o . &lt;&lt;&lt; "${NUMBER}" | while read DIGIT;  do
          declare -x FINALSUM="$(($FINALSUM+$DIGIT))"
      done
      echo $FINALSUM
  else
      echo $SOMA
  fi
  </code></pre>