title: Recursive method in Java is not working. Any ideas?
body: <p>I am trying to understand the recursive methods in Java and tried this simple method to calculate a factorial.
  Somehow it doesn't work. Can someone tell me why?</p>
  
  <pre><code>public class FactorialRecursive extends ConsoleProgram {
  
     public void run() {
        println("This program calculates the factorial of an integer n.");
        int n = readInt("Please insert n: ");
        int result = factorial(n);
        println("The factorial of " + n + " is " + result);
     }
  
     private int factorial(int n) {
        int total;
        if (n == 1) total = 1;
        total = n * factorial(n - 1);
        return (total);
     }
  }
  </code></pre>