Java code or program to find out the factorial of give number
import java.io.*;
class Test {
public static void main(String[] args) throws IOException {
int i=1,f=1,num;
System.out.println("Enter the number:");
BufferedReader br=new BufferedReader(new InputStreamReader (System.in));
num=Integer.parseInt(br.readLine());
while(i<=num){
f=f*i;
i++;
}
System.out.println("Factorial of "+num+" is:"+f);
}
No comments:
Post a Comment