Java program to fin factorial of a number

 import java.util.Scanner;

public class Main {

    public static void main(String[] args)

    {

    int fact=1,number,i;

    Scanner s =new Scanner(System.in);

    System.out.println("Enter the number to find factorial");

    number=s.nextInt();

    for(i=1;number>=i;i++)

    {

        fact=fact*i;

    }

    System.out.println("The factorial of the number is: "+fact);

    }

}


Comments

Popular Posts