title: Variables Multiplication for the factorial calculation
body: <p>I'm making a script that calculates the factorial for a given number, but I'm having some problems with the multiplication.</p>
  <p>Note: the factorial for is given by: <code>9!=9*8*7*6*5*4*3*2*1</code></p>
  <p>Here's my code:</p>
  <pre class="lang-bash prettyprint-override"><code>#!/bin/bash
  
  echo &quot;Insert an Integer&quot;
  
  read input
  
  if ! [[ &quot;$input&quot; =~ ^[0-9]+$ ]] ; then
     exec &gt;&amp;2; echo &quot;Error: You didn't enter an integer&quot;; exit 1
  fi
  
  function factorial
  {
  while [ &quot;$input&quot; != 1 ];
  do
      result=$(($result * $input))
      input=$(($input-1))
  done
  }
  factorial
  echo &quot;The Factorial of &quot; $input &quot;is&quot; $result
  </code></pre>
  <p>it keeps giving me errors of all kinds for different multiplication technics :/</p>
  <p>Currently the output is:</p>
  <blockquote>
  <pre><code>joaomartinsrei@joaomartinsrei ~/Área de Trabalho/Shell $ 
  ./factorial.sh
  Insert an Integer
  3
  ./factorial.sh: line 15: * 3: syntax error: operand expected (error token is &quot;* 3&quot;)
  The factorial of 3 is
  </code></pre>
  </blockquote>