09 April 2012

Calculate Factorial of a Number




public class Factorial {
public static void main(String[] args) {
int number = 5;

int factorial = number;
for(int i =(number - 1); i > 1; i--)
{
factorial = factorial * i;
}
System.out.println("Factorial of a number is " + factorial);
}
}

0 comments:

Post a Comment

Related Posts with Thumbnails

Popular Posts

 
;