title: Java for loop to get the sum of numbers
body: <p>I am writing a program that asks the user to input a positive integer and to calculate the sum from 1 to that number. Need some tips on what i'm doing wrong.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>public static void main(String[] args){
      Scanner keyboard = new Scanner(System.in);
      System.out.println("Enter a positive integer");
      int getNumber=keyboard.nextInt();
      int x;
      int total = 0;
      for (x=1;x&lt;=getNumber;x++) {
          total=x+1;
      }
      System.out.println(total);
  }
  </code></pre>