Output:
Click Here For Java Online Compiler
Solution:
*** Factorial Using For LOOp Only *** Find Factorial Of: 4 Factorial of 4 is: 24
Click Here For Java Online Compiler
Solution:
import java.util.Scanner; class FactorialUsingForLoop { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.println("*** Factorial Using For LOOp Only ***" + "\n"); System.out.print("Find Factorial Of: "); int factorialOf = scanner.nextInt(); long fact = 1; for (int i = 1; i <= factorialOf; i++) { fact = fact * i; } System.out.println("Factorial of " + factorialOf + " is: " + fact); } }
comment 0 comments:
more_vertsentiment_satisfied Emoticon