Factorial program in java

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);
     }

1 comment:

basant kumar said...

factorial hundred In the last few days, the “factorial of 100” is one of the top subjects and a lot of maths geeks compute it using voice assistants such as Alexa, Shiri, etc.