import java.util.Scanner; public class FactorialExample { public static double factorial(int n) { if (n<=1) return 1; return n*factorial(n-1); } public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.print("Enter a number: "); int value = sc.nextInt(); System.out.println(factorial(value)); sc.close(); } } //Copyright 2016 Evan Golub