title: factorial method doesn't work well!
body: <p>Hi
  this is a factorial method but it prints 0 in the console please help me thanks</p>
  
  <pre><code>public class Demo {
  
      public static void main(String[] args) {
          Demo obj = new Demo();
          System.out.println(obj.factorial(500));
      }
  
      public int factorial(int n) {
          int fact = 1;
  
          for (int i = 2; i &lt;= n; i++) {
              fact= fact*i;
          }
          return fact;
      }
  </code></pre>
  
  <p>EDITED:will return Infinity! </p>
  
  <pre><code>public class Demo {
  
      public static void main(String[] args) {
          Demo obj = new Demo();
          System.out.println(obj.factorial(500));
      }
  
      public double  factorial(long n) {
         double fact = 1;
  
          for (int i = 2; i &lt;= n; i++) {
              fact= fact*i;
          }
          return fact;
      }
  }
  </code></pre>