title: summation function in java
body: <p>I am getting strange behavior with this basic piece of java code</p>
  
  <pre><code>  public class Sigma {
         public static void main(String[] args) {
             int sum = sigma(3);
             System.out.println(sum);
         }
  
         public static int sigma(int n){
             int sum = 0;
             for (int i = 0; i &lt;= n; i++) {
                 sum += 1;
             }
             return sum;
         }
     }
  </code></pre>
  
  <p>The expected output is <code>6</code>, however when I run the code I get <code>4</code></p>