title: Recursive method that will compute the sum of the first n integers in an array of at least n integers. Begin with nth integer
body: <p>This is my code so far but when I run it and enter a value for n the program ends with "Sum of numbers is: " and that's all. Doesn't change no matter what value I enter, can you help me figure out what I'm doing wrong?</p>
  
  <pre><code>import java.util.Scanner;
  class addNum
  {
      //A method for Adding
      public static int addNum (int arr[], int n)
      {
        int x = 0;
        if (n &gt; arr.length)
        {
            return 0;
        }
        else if (n == 1)
        {
            return 1;
        }
        else 
        {
           x = arr[n-1] + addNum(arr, n);
           return n;
        }
       }
  
      public static void main(String args[])
      {
          int n = 0;
          int arr[] = {1,2,3,4,5,6,7};
          System.out.println("Input your number and press enter: ");
          Scanner in = new Scanner(System.in);
          n = in.nextInt();
          System.out.print("Sum of numbers is:");
          addNum(arr, n);
          System.out.println();
          }
      } 
  </code></pre>