title: Why is $(( sum += i )) in bash telling me "command not found"?
body: <p>The goal is to have a bash script that sums up the integers from 1 to N, with N being defined by the user. Here is my code:</p>
  
  <pre><code>#!/bin/bash
  
  read -p "Enter an integer greater than zero: " N  #allows the user to enter a value, which is then read from stdin and assigned to N
  
  sum=0
  
  for ((i=0; i&lt;=N; i++))
  
  do
  
    $((sum+=i))  #add i to sum each iteration
  
  done
  
  echo "The sum of the numbers from 1 to $N is $sum"
  </code></pre>
  
  <p>The output:</p>
  
  <pre><code>Enter an integer greater than zero: 5
  -bash: 0: command not found
  -bash: 1: command not found
  -bash: 3: command not found
  -bash: 6: command not found
  -bash: 10: command not found
  -bash: 15: command not found
  The sum of the numbers from 1 to 5 is 15
  </code></pre>
  
  <p>The summation is correct. I realize that the summation for each iteration is causing an error of some sort (b/c 0, 1, 3, 6...  is the value of the summation for each i), but I'm not sure why or how to fix it. Is there a way to debug in vi? Thanks</p>