Saturday, 18 August 2012

Java program to find a factorial of a given number


Java program to find a factorial of a  given number:
class FactorialNo{
      public static void main(String args[]){
       int  number = Integer.parseInt(args[0]);                 //take argument as command line
          int result = 1;
          while(number>0){
                result = result * number;
                number--;
          }
          System.out.println("Factorial of Given number is : "+result);
   }
}

No comments:

Post a Comment