Factorial Example : Java
class Factorial{
public static void main(String[] args) {
try
{
BufferedReader object = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the Number : ");
int a= Integer.parseInt(object.readLine());
int fact= 1;
System.out.println("Factorial of Number " +a+ ":");
for (int i= 1; i<=a; i++){
fact=fact*i;
}
System.out.println(fact);
}
catch (Exception e){}
}
}
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment