Java test - using "FOR"
/* ============ Factorial The factorial of a number N is equal to 1 * 2 * 3 * ... * N For example, the factorial of 5 is 1* 2 * 3 * 4 * 5 = 120. Request: Create a program that takes a number from input and output the factorial of that number. Tip: Use a for loop to make the calculation, and start the loop from the number 1. */ import java.util.Scanner; class Demo{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int x = sc.nextInt(); int fat = 1; for(int i=1;i<=x;i++){ fat = fat * i; System.out.println(fat); } } } // In all "test cases" the value is ok; // In "test case 1" (type 14) the result match as the expected (1278945280) //But I need to use something that the exercise request, someone have any idea?