JAVA Program to Find Factorial of Number

JAVA Program to Find Factorial of Number:


class fact
{
   public static void main(String a[])
     {
       int n;
       int fact=1;
       n=Integer.parseInt(a[0]);
       System.out.println("Given Number is : "+n);
       int no=n;
        while(n>0)
         {
          fact=fact*n;
          n--;
          }
         System.out.println(no+" !="+fact);
      }
}

OUTPUT:

Given Number is : 5
5 !=120

Leave a Reply

Your email address will not be published. Required fields are marked *

two + 13 =