title: How do I print factorials without using a loop?
body: <p>I made a recursive method to calculate factorials, but in the main method I have used a for loop to calculate the list of factorials. Is there a way to calculate a list of factorials without using a loop in the main method?</p>
  
  <p>Code:</p>
  
  <pre><code>public class FactInt {
      public static void main(String[] args) {
          for (int n = 1; n &lt; 11; n++)
              System.out.println(factorial(n));
      }
      //Calculates the factorial of integer n
      public static int factorial(int n) {
          if (n == 0)
              return 1;
          else 
              return n*factorial(n-1);
      }
  }
  </code></pre>