WAP to find factorial of a number using BufferedReader

import java.io.*;
class Factorial
{

public static void main(String args[])
{
BufferedReader bf=new BufferedReader( new InputStreamReader(System.in));
int a=0,f=1;
try
{
System.out.println("Enter the number to find factorial:");
a=Integer.parseInt(bf.readLine());
}
catch(Exception e)
{
  e.printStackTrace();
}
if(a==0||a==1)
System.out.println("factorial of this number is 1");
else
{
for(int i=a;i>0;i--)
{
f=f*i;
}
        System.out.println("factorial of this number is:"+f);
}
}
}
 

Comments