package tutorialJava.examenes.examen20241025;

public class EjC_FactorialMasCercano {

	public static void main(String[] args) {
		int num = 121;
		
		for(int i = 0; i < 10; i++) {
			if (factorial(i) > num) {
				System.out.println("El factorial más cercano es el de " + 
						(i - 1));
				break;
			}
		}
	}
	
	
	public static int factorial (int n) {
		int fact = 1;
		
		for (int i = 2; i <= n; i++) {
			fact *= i;
		}
		return fact;
	}

}
