Tue Apr 10, 2007 3:32 pm
3!= 3 X 2 X 1 = 6
/*
import java.util.Scanner;
/**
*
* @author mohamed
*/
public class Factor {
/** Creates a new instance of GCD */
public Factor() {
System.out.println("Factorial of number x! ");
Scanner inscan=new Scanner(System.in);
System.out.println("Please enter the number ");
a=inscan.nextInt();
System.out.println("("+a+") ! = "+get_Factor() );
}
public long get_Factor()
{
if(a<1)return 1;
long result=1;
long x=a;
while(x>1)
{
result*=x;
x--;
}
return result;
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
new Factor();
// TODO code application logic here
}
private int a;
}
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.