/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication5;
import java.util.Scanner;
/**
*
* @author hlavavla
*/
public class JavaApplication5 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Scanner sc = new Scanner(System.in, "Windows-1250");
System.out.println("Zadejte číslo v rozmezí 1 až 40:");
int a = Integer.parseInt(sc.nextLine());
a = fact(a);
System.out.printf("Vypočteno: %d \n",a);
}
static int fact(int n) {
// Base Case:
// If n <= 1 then n! = 1.
if (n <= 1) {
return 1;
}
// Recursive Case:
// If n > 1 then n! = n * (n-1)!
else {
return n * fact(n-1);
}
}
}