How To Write Factorial Program In Java?

4

4 Answers

Anonymous Profile
Anonymous answered
/*Write a program to Find Factorial of Given no. */

class Factorial{

  public static void main(String args[]){

  int num = Integer.parseInt(args[0]);   //take argument as command line

  int result = 1;

  while(num>0){

  result = result * num;

  num--;

  }

  System.out.printl of Given no. Is : "+result);

   }

}
Anonymous Profile
Anonymous answered
Public class Factorial{
public static void main (String args [ ]) {
int n=5,f=1,I;
for(I=n;I>0;I--)
{
f=I*f;
}
System.out.println ("f");
}
}
Anonymous Profile
Anonymous answered
Public class factorial
{
Anonymous Profile
Anonymous answered
Int x;
x = e.nextint();
double f=1;
for(int I=1;I

Answer Question

Anonymous