package cn.edu.bjut.chapter3; public class Factorial { static int calculate(int n) { if (n == 0) { return 1; } else { return (n * calculate(n - 1)); } } public static void main(String[] args) { int n = 5; System.out.println(n + "! = " + calculate(n)); } }