Output:
Click Here For Java Online Compiler
Solution:
*** Factorial Program *** Enter the number: 10 Factorial of 10 is: 3628800
Click Here For Java Online Compiler
Solution:
import java.util.Scanner; class FactorialInputNumber { public static void main(String[] args) { int number; System.out.println("*** Factorial Program ***" + "\n"); System.out.print("Enter the number: "); Scanner sc = new Scanner(System.in); number = sc.nextInt(); long fact = 1; int i = 1; while (i <= number) { fact = fact * i; i++; } System.out.println("Factorial of " + number + " is: " + fact); } }
comment 0 comments:
more_vertsentiment_satisfied Emoticon